/* Archive Structure Workbench - Styles */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #6b7280;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f9fafb;
    --bg-secondary: #f3f4f6;
    --text: #111827;
    --foreground: #111827;
    --accent: #2563eb;
    --border: #e5e7eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.debug-ui [data-ui-id] { outline: 2px dashed rgba(156, 39, 176, .7); outline-offset: -2px; position: relative; }
.debug-ui .ui-debug-label { position: absolute; z-index: 20; top: 0; left: 0; padding: .1rem .3rem; background: #6a1b9a; color: #fff; font: 600 10px/1.2 monospace; pointer-events: none; }

/* Navbar */
.navbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

.nav-links a {
    margin-left: 1.5rem;
    color: var(--secondary);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav-links a { margin-left: 0; }

.user-menu { position: relative; }
.user-menu summary {
    color: var(--secondary);
    font-size: 0.9rem;
    cursor: pointer;
    list-style: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: " ▾"; }
.user-menu-panel {
    position: absolute;
    right: 0;
    z-index: 20;
    min-width: 180px;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.user-menu-panel a { display: block; padding: 0.5rem 0.75rem; }

/* Main content */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: #fff;
    color: var(--secondary);
    border-color: var(--border);
}

.btn-secondary:hover { background: var(--bg); }

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--secondary);
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.data-table th {
    background: var(--bg);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

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

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

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Login */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Maintainer diagnostics */
.diagnostics-card {
    background: #111827;
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
}

.diagnostics-json {
    color: #d1fae5;
    font: 0.82rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    margin: 0;
    white-space: pre-wrap;
}

.diagnostics-card h2, .diagnostics-card h3 { color: #f9fafb; margin-top: 0; }
.diagnostics-card p, .diagnostics-card dd, .diagnostics-card li { color: #d1d5db; }
.diagnostics-card a { color: #93c5fd; }
.diagnostics-timeline, .diagnostics-evidence-list { margin: 0; padding-left: 1.5rem; }
.diagnostics-timeline > li, .diagnostics-evidence-list > li { border-left: 2px solid #4b5563; margin: 0 0 1rem; padding: 0 0 0.5rem 1rem; }
.diagnostics-timeline-heading { display: flex; justify-content: space-between; gap: 1rem; color: #f9fafb; }
.diagnostics-timeline time, .diagnostics-evidence-list small { color: #9ca3af; font-size: 0.78rem; }
.diagnostics-evidence-list span { display: inline-block; margin: 0.35rem 0; white-space: pre-wrap; }
.diagnostics-evidence-list small { display: block; }
.diagnostics-facts { display: grid; grid-template-columns: minmax(10rem, 18rem) 1fr; gap: 0.5rem 1rem; }
.diagnostics-facts dt { color: #9ca3af; }
.diagnostics-facts dd { margin: 0; }
.diagnostics-reasoning { color: #fde68a; font: 0.85rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; max-height: 42rem; overflow: auto; }
.diagnostics-tool-events { padding-left: 1.25rem; }
.diagnostics-raw summary { cursor: pointer; color: #f9fafb; }
.diagnostics-raw summary h2 { display: inline; }

/* Actions */
.actions {
    margin: 1.5rem 0;
    display: flex;
    gap: 0.5rem;
}

/* Messages */
.message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.message-success { background: #dcfce7; color: #166534; }
.message-error { background: #fee2e2; color: #991b1b; }
.message-warning { background: #fef3c7; color: #92400e; }

/* Guidelines */
.guidelines section {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.guidelines h2 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.guidelines ul {
    margin-left: 1.5rem;
}

.guidelines li {
    margin-bottom: 0.25rem;
}

/* Sections */
h1 { margin-bottom: 1rem; }
h2 { margin: 1.5rem 0 0.5rem; font-size: 1.2rem; }
h3 { margin: 1rem 0 0.5rem; font-size: 1.1rem; }
h4 { margin: 0.75rem 0 0.5rem; font-size: 1rem; }

/* Footer */
.footer {
    margin-top: 3rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--secondary);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Document workspace (collapsible navigator · OpenSeadragon viewer · resizable inspector) ===== */
/* The workspace uses nearly the full viewport: break out of the site's content width for this page only. */
body[data-workspace="document_detail"] .main-content { max-width: none; margin: 0; padding: 0; }
body[data-workspace="document_detail"] .footer { display: none; }

.workspace-shell { display: flex; flex-direction: column; height: 100vh; min-height: 480px; background: #f9fafb; }
.workspace-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem 1rem; background: #fff; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.workspace-title h1 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.workspace-title .eyebrow { margin: 0; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--secondary); }
.workspace-meta { margin: 0; color: var(--secondary); font-size: .8rem; }
.workspace-actions { display: flex; gap: .5rem; align-items: center; }

.workspace-stage { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }

/* Page navigator (collapsible rail) */
.page-navigator { flex: 0 0 auto; width: 160px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: width .18s ease, opacity .18s ease; }
.page-navigator.is-collapsed { width: 0; opacity: 0; overflow: hidden; border-right: none; }
.page-navigator-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.page-navigator-head h2 { margin: 0; font-size: .85rem; }
.page-list { flex: 1 1 auto; overflow-y: auto; padding: .5rem; }
.page-list-item { display: block; position: relative; width: 100%; background: none; border: 2px solid transparent; border-radius: 7px; padding: .35rem; margin-bottom: .4rem; font-size: .78rem; color: var(--text); cursor: pointer; text-align: left; }
.page-list-item:hover, .page-list-item.is-selected { border-color: var(--primary); background: #eff6ff; }
.page-list-item img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #f3f4f6; margin-bottom: .25rem; }
.page-number { position: absolute; z-index: 1; top: .45rem; left: .45rem; padding: 0 .25rem; background: rgba(255,255,255,.9); border-radius: 3px; font-weight: 700; }
.page-navigator-collapse, .page-navigator-opener { flex: 0 0 auto; align-self: center; }
.page-navigator-opener { width: 18px; margin-left: .35rem; padding: 0; background: #fff; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; color: var(--secondary); }
.page-navigator-opener:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--secondary); font-size: 1rem; line-height: 1; padding: .15rem .25rem; border-radius: 4px; }
.icon-btn:hover { color: var(--primary); background: #eff6ff; }

/* Viewer pane (OpenSeadragon host) */
.viewer-pane { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: #e5e7eb; }
.viewer-toolbar { flex: 0 0 auto; display: flex; align-items: center; gap: .35rem; padding: .4rem .55rem; background: #fff; border-bottom: 1px solid var(--border); }
.viewer-page-indicator { font-size: .8rem; color: var(--secondary); min-width: 5rem; }
.viewer-toolbar-spacer { flex: 1 1 auto; }
.viewer-host { flex: 1 1 auto; position: relative; min-height: 0; overflow: hidden; }
/* Truthful loading/empty/error states — these are driven by the viewer state
   machine (never a timer) and "no image" is never used as a loading surrogate. */
.viewer-status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--secondary); padding: 2rem; text-align: center; pointer-events: none; }
.viewer-status .is-loading { display: flex; align-items: center; gap: .6rem; }
.viewer-status .is-preview { font-size: .8rem; color: var(--secondary); background: rgba(255,255,255,.7); padding: .25rem .6rem; border-radius: 999px; }
.viewer-status .is-error { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
/* Unobtrusive preview badge pinned to the bottom — never covers the page. */
.viewer-status:has(.viewer-status-badge) { place-items: end center; padding: .6rem; }
.viewer-status-badge { font-size: .75rem; color: var(--secondary); background: rgba(255,255,255,.88); border: 1px solid rgba(0,0,0,.08); padding: .25rem .6rem; border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.viewer-status[hidden] { display: none; }
.viewer-spinner { width: 1.25rem; height: 1.25rem; border: 2.5px solid rgba(37,99,235,.2); border-top-color: var(--primary); border-radius: 50%; animation: viewer-spin .8s linear infinite; }
@keyframes viewer-spin { to { transform: rotate(360deg); } }
.viewer-legend { flex: 0 0 auto; padding: .4rem .65rem; background: #fff; border-top: 1px solid var(--border); color: var(--secondary); font-size: .75rem; }
.legend-swatch { display: inline-block; width: .7rem; height: .7rem; margin-right: .3rem; vertical-align: -.05rem; border: 1px solid rgba(37,99,235,.7); background: rgba(37,99,235,.12); }

/* Region overlays rendered by OpenSeadragon. They are visual only
   (pointer-events: none) so dragging always pans; selection uses canvas-click. */
.region-overlay { pointer-events: none; box-sizing: border-box; border: 1.5px solid rgba(37,99,235,.7); background: rgba(37,99,235,.08); transition: background .15s, border-color .15s; }
.region-overlay:focus-visible { outline: 2px solid #d97706; outline-offset: 1px; }
.region-overlay.is-selected { border-color: #d97706; border-width: 2.5px; background: rgba(245,158,11,.22); }
.region-overlay.region-text { border-color: rgba(37,99,235,.7); }
.region-overlay.region-title { border-color: rgba(5,150,105,.8); background: rgba(16,185,129,.10); }
.region-overlay.region-table { border-color: rgba(124,58,237,.7); background: rgba(124,58,237,.08); }
.region-overlay.region-figure { border-color: rgba(107,114,128,.7); background: rgba(107,114,128,.07); }
.region-overlay.is-suppressed { border-style: dashed; opacity: .45; }
.region-overlay-number { position: absolute; top: 0; left: 0; padding: 0 .25rem; background: rgba(255,255,255,.85); color: #1f2937; font-size: 10px; font-weight: 700; border-radius: 0 0 4px 0; }
.region-overlay.is-selected .region-overlay-number { background: #d97706; color: #fff; }
.htr-line-overlay { pointer-events: none; border: 1.5px solid #d97706; background: rgba(217,119,6,.18); }

/* Draggable vertical splitter */
.splitter { flex: 0 0 auto; width: 7px; margin-left: -1px; cursor: col-resize; background: var(--border); border-left: 1px solid var(--border); border-right: 1px solid #fff; position: relative; }
.splitter::after { content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 3px; height: 34px; border-radius: 3px; background: #cbd5e1; }
.splitter:hover::after, .splitter:focus-visible::after, .splitter.is-dragging::after { background: var(--primary); }
.splitter:focus-visible { outline: none; box-shadow: -2px 0 0 var(--primary), 2px 0 0 var(--primary); }
body.is-splitter-dragging { cursor: col-resize; user-select: none; }

/* Region inspector */
.region-inspector { flex: 0 0 auto; width: 440px; min-width: 360px; max-width: 700px; background: #fff; border-left: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.inspector-empty { flex: 1 1 auto; display: grid; place-items: center; padding: 2rem; }
.inspector-empty-card { color: var(--secondary); text-align: center; max-width: 24rem; }
.inspector-empty-card h2 { margin: 0 0 .5rem; color: var(--text); }

/* Persistent Region/Page tab shell (kept outside the swapped panes). */
.inspector-tabs { flex: 0 0 auto; display: flex; gap: .25rem; padding: .5rem .8rem 0; }
.inspector-tab { flex: 1 1 0; padding: .4rem .5rem; border: 1px solid var(--border); border-bottom: none; background: #f8fafc; border-radius: 7px 7px 0 0; color: var(--secondary); font-size: .85rem; cursor: pointer; }
.inspector-tab.is-active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 -1px 0 #fff; }
.inspector-tab:disabled { opacity: .5; cursor: not-allowed; }
#inspector-pane-region, #inspector-pane-page { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* Viewer region-filter controls (viewer concern, not inspector). */
.viewer-filter { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--secondary); white-space: nowrap; }
.viewer-filter select { padding: .2rem .35rem; font-size: .8rem; border: 1px solid var(--border); border-radius: 5px; }
.viewer-filter-check input { margin: 0; }

/* Page-tab inspector content. */
.page-full-text { margin: .3rem .8rem .6rem; padding: .6rem; border: 1px solid var(--border); border-radius: 8px; background: #f9fafb; font-size: .88rem; line-height: 1.5; white-space: pre-wrap; max-height: 16rem; overflow-y: auto; }
.page-table { margin: .3rem .8rem .5rem; }
.page-table summary { cursor: pointer; font-size: .85rem; color: var(--primary); }
.table-preview { margin-top: .4rem; font-size: .82rem; overflow-x: auto; }
.table-preview table { border-collapse: collapse; width: 100%; }
.table-preview td, .table-preview th { border: 1px solid var(--border); padding: .25rem .4rem; }

.inspector { display: flex; flex-direction: column; gap: .1rem; }
.inspector-alert { margin: .6rem .8rem 0; padding: .5rem .65rem; border-radius: 6px; background: #fef2f2; color: #b91c1c; font-size: .85rem; border: 1px solid #fecaca; }
.inspector-status[data-kind="error"] { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.inspector-status:not([hidden]) { margin: .4rem .8rem 0; padding: .45rem .6rem; border-radius: 6px; border: 1px solid var(--border); font-size: .82rem; }
.inspector-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .7rem .8rem; border-bottom: 1px solid var(--border); }
.inspector-head-main { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.inspector-head h2 { margin: 0; font-size: 1rem; }
.inspector-menu { position: relative; }
.inspector-menu > summary { list-style: none; cursor: pointer; font-size: 1.15rem; color: var(--secondary); padding: .15rem .35rem; border-radius: 4px; }
.inspector-menu > summary::-webkit-details-marker { display: none; }
.inspector-menu[open] > summary { background: #eff6ff; color: var(--primary); }
.inspector-menu-panel { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 220px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px #0000001a; padding: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.menu-field { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--secondary); }
.menu-field select { padding: .3rem; font-size: .85rem; border: 1px solid var(--border); border-radius: 5px; }
.inspector-section-label { padding: .6rem .8rem .2rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--secondary); }

/* Transcription editor */
.inspector-editor { padding: 0 .8rem .6rem; border-bottom: 1px solid var(--border); }
.transcription-area { width: 100%; box-sizing: border-box; resize: none; overflow: hidden; min-height: 96px; padding: .6rem; font: inherit; font-size: .95rem; line-height: 1.5; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.transcription-area:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.transcription-area[readonly] { background: #f9fafb; }
.transcription-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .4rem; }
.dirty-state { font-size: .8rem; color: var(--secondary); min-height: 1.1rem; }
.dirty-state[data-state="dirty"] { color: #b45309; font-weight: 600; }
.transcription-meta-actions { display: flex; gap: .4rem; }

/* Recognition split buttons */
.recognition-controls { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.split-button { position: relative; display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: visible; background: #fff; }
.split-button-main { display: inline-flex; align-items: center; gap: .45rem; border: none; background: var(--primary); color: #fff; padding: .45rem .7rem; font-size: .82rem; border-radius: 7px 0 0 7px; cursor: pointer; }
.split-button-main:hover { background: var(--primary-hover); }
.split-button-label { font-weight: 600; }
.split-button-model { font-size: .76rem; opacity: .9; }
.split-button-menu > summary { list-style: none; cursor: pointer; border-left: 1px solid rgba(255,255,255,.35); background: var(--primary-hover); color: #fff; padding: .45rem .45rem; border-radius: 0 7px 7px 0; font-size: .7rem; }
.split-button-menu > summary::-webkit-details-marker { display: none; }
.split-button-menu-panel { position: absolute; top: 100%; left: 0; z-index: 20; min-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px #0000001a; padding: .25rem; display: flex; flex-direction: column; }
.split-button-menu-panel button { text-align: left; background: none; border: none; padding: .4rem .5rem; font-size: .82rem; cursor: pointer; border-radius: 5px; color: var(--text); }
.split-button-menu-panel button:hover { background: #eff6ff; }
.split-button-menu-panel button[aria-checked="true"] { font-weight: 700; color: var(--primary); }

/* Versions / provenance rail */
.inspector-versions { padding: 0 .8rem .8rem; }
.version-current { padding: .5rem .6rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; margin-top: .4rem; }
.version-current-head { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--secondary); }
.version-current-source { color: #92400e; font-weight: 600; }
.version-current-text { margin: .35rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .85rem; }
.version-rail { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.version-item { position: relative; display: flex; align-items: center; gap: .35rem; }
.version-select { flex: 1 1 auto; display: flex; flex-direction: column; gap: .1rem; text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 7px; padding: .4rem .5rem; cursor: pointer; font-size: .82rem; }
.version-select:hover:not(:disabled) { border-color: var(--primary); background: #eff6ff; }
.version-select:disabled { cursor: default; opacity: .8; }
.version-item.is-accepted .version-select { border-color: #d97706; background: #fffbeb; }
.version-item.is-pending .version-rail-main::after { content: " ⏳"; }
.version-rail-main { display: flex; align-items: center; gap: .35rem; font-weight: 600; }
.version-rail-meta { color: var(--secondary); font-size: .72rem; }
.version-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; border: 1.5px solid #9ca3af; background: #fff; flex: 0 0 auto; }
.version-dot.is-current { background: #d97706; border-color: #d97706; }
.version-dot.is-completed { background: #10b981; border-color: #10b981; }
.version-dot.kind-htr { border-color: #b45309; }
.version-dot.kind-vision { border-color: #7c3aed; }
.version-dot.kind-manual { border-color: #2563eb; }
.version-dot.kind-imported { border-color: #6b7280; }
.version-badge { font-size: .68rem; color: #92400e; background: #fef3c7; border-radius: 1rem; padding: .05rem .4rem; }
.version-lines { background: none; border: 1px solid var(--border); border-radius: 5px; font-size: .72rem; cursor: pointer; color: var(--secondary); padding: .15rem .4rem; }
.version-lines:hover { color: #b45309; border-color: #d97706; }
.version-text { display: none; }

/* Candidate comparison */
.version-compare { margin-top: .6rem; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; background: #f9fafb; }
.version-compare-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.version-compare-body { margin: .4rem 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; line-height: 1.5; }
.version-compare-body del { background: #fee2e2; color: #b91c1c; text-decoration: line-through; }
.version-compare-body ins { background: #dcfce7; color: #166534; text-decoration: none; }
.version-compare-actions { display: flex; justify-content: flex-end; }
.btn-ghost { background: none; border: none; color: var(--secondary); cursor: pointer; font-size: .9rem; }
.version-activity { margin-top: .6rem; font-size: .8rem; }
.version-activity > summary { cursor: pointer; color: var(--secondary); }
.version-activity-list { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.version-activity-list li { display: flex; flex-direction: column; padding: .25rem 0; border-bottom: 1px dashed var(--border); }
.activity-label { font-weight: 600; }
.activity-meta { color: var(--secondary); font-size: .74rem; }

/* Shared badges / empty state */
.badge { display: inline-block; padding: .125rem .5rem; background: #dcfce7; color: #065f46; border-radius: 1rem; font-size: .75rem; }
.region-type-badge { background: #eff6ff; color: #1e40af; }
.empty-state { color: var(--secondary); padding: 1rem; }
.help-text { color: var(--secondary); font-size: .85rem; margin: .5rem 0; }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }

/* Evidence-grounded research workspace */
.chat-workspace { max-width: 1500px; margin: 0 auto; }
.chat-page-header { align-items: end; }
.eyebrow { color: var(--primary); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .25rem; }
.chat-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr) minmax(320px, 380px); gap: 1rem; align-items: stretch; height: min(760px, calc(100vh - 190px)); min-height: 560px; }
.chat-sessions, .chat-panel, .chat-context { background: #fff; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.chat-sessions, .chat-context { padding: .8rem; }
.chat-sidebar-heading, .chat-panel-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.chat-sidebar-heading { padding: .25rem .2rem .65rem; border-bottom: 1px solid var(--border); }
.chat-sidebar-heading h2 { margin: 0; font-size: .95rem; }
.chat-sidebar-heading span { color: var(--secondary); font-size: .78rem; }
.chat-session-list { display: grid; gap: .35rem; padding-top: .65rem; }
.chat-session { display: block; padding: .65rem; border-radius: 7px; color: var(--text); text-decoration: none; }
.chat-session:hover, .chat-session.is-selected { background: #eff6ff; color: var(--primary); }
.chat-session strong, .chat-session small, .chat-document-list strong, .chat-document-list small, .chat-evidence-list small { display: block; overflow-wrap: anywhere; }
.chat-session small, .chat-document-list small, .chat-evidence-list small { color: var(--secondary); font-size: .72rem; margin-top: .15rem; }
.chat-panel { display: flex; flex-direction: column; overflow: hidden; }
.chat-panel-header { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.chat-panel-header h2 { margin: 0; font-size: 1.05rem; }
.chat-panel-header span { color: var(--secondary); font-size: .78rem; }
.chat-status-label { color: #166534 !important; background: #dcfce7; border-radius: 999px; padding: .2rem .5rem; white-space: nowrap; }
.chat-messages { flex: 1; padding: 1rem; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.chat-message { max-width: 86%; margin-bottom: .9rem; padding: .8rem 1rem; border-radius: 9px; border: 1px solid var(--border); }
.chat-message-user { margin-left: auto; background: #eff6ff; border-color: #bfdbfe; }
.chat-message-assistant { background: #f9fafb; }
.message-role { color: var(--secondary); font-size: .72rem; font-weight: 700; margin-bottom: .3rem; }
.message-body p { margin: 0 0 .45rem; }
.message-body p:last-child { margin-bottom: 0; }
.chat-citation { display: inline-block; margin: 0 .08rem; padding: 0 .22rem; border-radius: 4px; background: #dbeafe; color: #1d4ed8; font-weight: 700; text-decoration: none; }
.chat-citation:hover, .chat-citation:focus { background: #bfdbfe; text-decoration: underline; }
.chat-question-form { position: sticky; bottom: 0; display: flex; gap: .6rem; align-items: end; padding: .9rem 1rem; border-top: 1px solid var(--border); background: #fff; z-index: 2; }
.chat-question-form textarea, .chat-start-form textarea { flex: 1; width: 100%; resize: vertical; padding: .65rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.composer-main { flex: 1; min-width: 0; }
.scope-summary { display: block; color: var(--secondary); font-size: .72rem; margin-top: .3rem; }
.chat-empty-start { padding: 2rem 1.2rem .5rem; }
.chat-empty-start h2 { margin-top: 0; }
.chat-start-form { padding: 1rem 1.2rem; }
.chat-start-form fieldset { border: 0; margin-bottom: 1rem; }
.chat-start-form legend { font-weight: 700; margin-bottom: .5rem; }
.checkbox-row { display: flex; gap: .5rem; align-items: start; padding: .45rem 0; }
.checkbox-row span, .checkbox-row small { display: block; }
.checkbox-row small { color: var(--secondary); font-size: .75rem; }
.chat-start-form > label { display: block; font-weight: 700; margin-bottom: .35rem; }
.chat-start-form .btn { margin-top: .7rem; }
.chat-context { display: grid; align-content: start; gap: 1.2rem; overflow: hidden; }
.chat-context section { min-width: 0; }
.chat-context-intro { color: var(--secondary); font-size: .78rem; padding: .65rem .2rem; }
.chat-document-list, .chat-evidence-list { list-style: none; display: grid; gap: .55rem; padding: .7rem .2rem 0; }
.chat-document-list li, .chat-evidence-list li { padding-bottom: .55rem; border-bottom: 1px solid var(--border); font-size: .8rem; }
.chat-evidence-list a { color: var(--primary); font-weight: 600; }
.chat-citation.is-selected { outline: 2px solid #2563eb; outline-offset: 2px; }
.evidence-reader-panel, .run-inspector { min-width: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.evidence-reader-header { display: flex; justify-content: space-between; gap: .75rem; align-items: start; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.evidence-reader-header h2 { margin: 0; overflow-wrap: anywhere; }
.evidence-meta { color: var(--secondary); font-size: .78rem; margin: .25rem 0 0; overflow-wrap: anywhere; }
.icon-button { border: 1px solid var(--border); background: #fff; border-radius: 5px; font-size: 1.2rem; line-height: 1; padding: .25rem .5rem; cursor: pointer; }
.evidence-navigation { display: flex; justify-content: space-between; align-items: center; padding: .7rem 0; gap: .4rem; }
.evidence-navigation span { color: var(--secondary); font-size: .78rem; }
.evidence-tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); }
.evidence-tabs button { border: 0; background: transparent; padding: .55rem .65rem; cursor: pointer; color: var(--secondary); }
.evidence-tabs button[aria-selected="true"] { color: var(--primary); border-bottom: 2px solid var(--primary); font-weight: 700; }
.evidence-view { padding-top: .8rem; min-width: 0; }
.matching-label { color: var(--secondary); font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.evidence-view blockquote { margin: .4rem 0 1rem; padding: .75rem; border-left: 3px solid #2563eb; background: #eff6ff; white-space: pre-wrap; overflow-wrap: anywhere; }
.evidence-view pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; background: #f8fafc; padding: .7rem; font: inherit; }
.evidence-page-tools { display: flex; gap: .35rem; margin-bottom: .5rem; }
.evidence-page-viewport { min-height: 220px; max-height: 420px; overflow: auto; background: #f8fafc; display: grid; place-items: center; padding: .5rem; }
.evidence-page-viewport img { max-width: none; width: 100%; height: auto; transform-origin: center top; }
.evidence-facts { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; font-size: .8rem; }
.evidence-facts dt { color: var(--secondary); }
.evidence-facts dd { margin: 0; overflow-wrap: anywhere; }
.evidence-reader-footer { padding: 1rem 0; }
.run-inspector { background: #fff; }
.inspector-body { padding-top: .8rem; font-size: .8rem; overflow-wrap: anywhere; }
.inspector-summary { display: grid; gap: .35rem; padding: .75rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; }
.inspector-phases, .inspector-evidence { padding-left: 1.2rem; display: grid; gap: .5rem; }
.inspector-phases li { display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; border-left: 3px solid #86efac; padding-left: .5rem; }
.inspector-phases li.is-failed { border-color: #ef4444; }
.inspector-phases li span { grid-column: 1 / -1; color: var(--secondary); }
.inspector-phases li small { color: var(--secondary); }
.inspector-body pre { max-height: 250px; overflow: auto; white-space: pre-wrap; }
.run-failure-label { color: #b91c1c; font-size: .78rem; }
.chat-sessions, .chat-context { overflow-y: auto; overscroll-behavior: contain; }
.chat-run-status { display: flex; gap: .6rem; align-items: center; padding: .8rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 7px; color: #92400e; }
.chat-run-status span { font-size: .8rem; }
@media (max-width: 1050px) { .chat-shell { grid-template-columns: 190px minmax(0, 1fr) minmax(280px, 330px); gap: .65rem; } }
@media (max-width: 820px) { .chat-shell { grid-template-columns: 170px minmax(0, 1fr); } .chat-context { position: fixed; inset: 1rem; z-index: 10; box-shadow: 0 10px 40px #0003; } .chat-context[data-open="false"] { position: static; box-shadow: none; } }
@media (max-width: 600px) { .chat-shell { display: block; height: auto; min-height: 0; } .chat-sessions { max-height: 160px; margin-bottom: .65rem; } .chat-panel { min-height: calc(100vh - 270px); } .chat-context { position: fixed; inset: .5rem; } .chat-context[data-open="false"] { position: static; } .chat-question-form { display: block; } .chat-question-form .btn { margin-top: .6rem; width: 100%; } .chat-message { max-width: 100%; } .evidence-reader-panel, .run-inspector { height: calc(100vh - 1rem); } }

@media (max-width: 950px) {
    .page-navigator { width: 120px; }
    .region-inspector { min-width: 320px; width: 380px; }
}
@media (max-width: 720px) {
    .page-navigator { width: 96px; }
    .page-list-item img { aspect-ratio: 3 / 4; }
    /* No tiny three-column view: hide the splitter drag on small screens and let the inspector overlay. */
    .splitter { display: none; }
    .region-inspector { position: absolute; inset: 0; width: 100%; max-width: 100%; min-width: 0; z-index: 30; box-shadow: -10px 0 30px #0003; }
    .region-inspector[hidden], .region-inspector.is-hidden-mobile { transform: translateX(100%); }
    .workspace-header { flex-wrap: wrap; }
}

/* Primary actions (dashboard) */
.primary-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.action-card {
    display: block;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--foreground);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.action-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.action-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.action-card h2 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
}

.action-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--secondary);
}

/* Settings page */
.settings-grid {
    display: grid;
    gap: 2rem;
}

.settings-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.settings-section h2 {
    margin-top: 0;
}

.settings-form {
    max-width: 500px;
}

.settings-form .form-group {
    margin-bottom: 1rem;
}

.settings-form label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.settings-form select,
.settings-form input[type="text"],
.settings-form input[type="password"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.help-text {
    font-size: 0.8rem;
    color: var(--secondary);
    margin-top: 0.25rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group label {
    margin-bottom: 0;
}

.scope-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    margin: 0.125rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 0.75rem;
    font-family: monospace;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 { margin-bottom: 0.25rem; }
.page-intro { color: var(--secondary); max-width: 700px; }
.eyebrow {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboard-section { margin: 2rem 0; }
.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.section-heading h2 { margin: 0; }
.section-heading a { color: var(--primary); text-decoration: none; }
.item-list {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}
.item-row:last-child { border-bottom: 0; }
a.item-row:hover { background: var(--bg); }
.item-row small { display: block; color: var(--secondary); margin-top: 0.125rem; }
.status-badge {
    flex: none;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--secondary);
    font-size: 0.78rem;
}
.status-active { background: #dbeafe; color: #1d4ed8; }
.status-ready { background: #dcfce7; color: #166534; }
.status-warning { background: #fef3c7; color: #92400e; }
.empty-state { padding: 2rem; text-align: center; }
.empty-state h2, .empty-state h3 { margin-top: 0; }
.empty-state p { color: var(--secondary); margin-bottom: 1rem; }
.evaluation-summary {
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
}

.upload-container { max-width: 760px; margin: 0 auto; }
.upload-form {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
}
.form-step { display: flex; gap: 1rem; padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.step-number {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    flex: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}
.step-content { flex: 1; min-width: 0; }
.step-content > label:first-child { display: block; font-weight: 700; margin-bottom: 0.5rem; }
.step-content > small { display: block; color: var(--secondary); margin-top: 0.35rem; }
.step-content select {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}
.file-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 2rem;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: #eff6ff; }
.file-drop.has-file { border-color: var(--success, #16a34a); background: #f0fdf4; }
.file-drop.has-error { border-color: #dc2626; background: #fef2f2; }
.region-detail-back { margin-left: auto; }
.correction-block { margin: 0.5rem 0 1rem; padding: 0.75rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; }
.correction-block-title { margin: 0 0 0.4rem; font-size: 0.9rem; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop span { color: var(--secondary); font-size: 0.85rem; }
.file-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    margin-top: 0.35rem;
}
.file-selected-name { font-weight: 600; color: var(--text, #111827); }
.file-selected-meta { color: var(--secondary); }
.file-selected-ok { color: var(--success, #16a34a); font-weight: 600; }
.file-drop.has-error .file-selected-ok { color: #dc2626; font-weight: 400; }
.file-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.file-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}
.file-item-error { border-color: #fecaca; background: #fef2f2; }
.file-item-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-item-name { font-weight: 600; color: var(--text, #111827); overflow-wrap: anywhere; }
.file-item-meta { color: var(--secondary); font-size: 0.82rem; }
.file-item-ok { color: var(--success, #16a34a); font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.file-item-error .file-item-meta { color: #dc2626; }
.file-item-status { font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.file-item.uploading .file-item-status { color: var(--primary); }
.file-item.done .file-item-status { color: var(--success, #16a34a); }
.file-item.error .file-item-status { color: #dc2626; }
.file-item.uploading .file-item-remove,
.file-item.done .file-item-remove { display: none; }
.file-item-remove {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    font-size: 0.82rem;
}
.file-item-remove:hover { border-color: var(--primary); }
.file-summary { margin: 0.5rem 0 0; color: var(--secondary); font-size: 0.85rem; font-weight: 600; }
.file-drop-pick { margin-top: 0.25rem; }
.analysis-option {
    display: flex;
    gap: 0.75rem;
    padding: 0.9rem;
    margin: 0.5rem 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.analysis-option.selected-option { border-color: var(--primary); background: #eff6ff; }
.analysis-option small { display: block; color: var(--secondary); }
.advanced-options { margin-top: 0.75rem; }
.advanced-options summary { color: var(--primary); cursor: pointer; }
.advanced-options > p { color: var(--secondary); font-size: 0.85rem; margin: 0.5rem 0; }
.next-explanation { margin-top: 1.25rem; padding: 1rem; background: var(--bg-secondary); border-radius: 8px; }
.next-explanation p { color: var(--secondary); margin-top: 0.25rem; }
.no-project-access { margin-top: 1.5rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.workflow-steps { margin: 2rem 0; list-style: none; counter-reset: steps; }
.workflow-steps li { display: flex; flex-direction: column; margin: 1rem 0; padding-left: 3rem; position: relative; }
.workflow-steps li::before {
    counter-increment: steps;
    content: counter(steps);
    position: absolute;
    left: 0;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    color: white;
}
.workflow-steps span { color: var(--secondary); }

@media (max-width: 760px) {
    .nav-container { align-items: flex-start; gap: 1rem; }
    .nav-links { flex-wrap: wrap; justify-content: flex-end; gap: 0.75rem; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .form-step { flex-direction: column; }
    .item-row { align-items: flex-start; }
}

/* ----- Document workspace export menu (document / project text export) ----- */
.export-menu { position: relative; display: inline-block; }
.export-menu > summary { list-style: none; cursor: pointer; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu-items {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: .25rem;
    min-width: 12rem;
    display: flex;
    flex-direction: column;
    background: var(--bg, #fff);
    border: 1px solid #d1d5db;
    border-radius: .375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
    z-index: 20;
    overflow: hidden;
}
.export-menu-items a { padding: .5rem .75rem; color: var(--text, #111); text-decoration: none; }
.export-menu-items a:hover { background: #f3f4f6; }
.export-menu:not([open]) .export-menu-items { display: none; }

/* ----- Search results (highlighted, grouped by document) ----- */
mark { background: #fde68a; color: inherit; padding: 0 .1em; border-radius: 2px; }
.search-summary { display: flex; align-items: baseline; gap: .6rem; margin: 1.5rem 0 .75rem; }
.search-summary h2 { margin: 0; font-size: 1.1rem; }
.search-summary-sub { color: var(--secondary); font-size: .9rem; margin: 0; }
.search-groups { display: flex; flex-direction: column; gap: 1rem; }
.search-group { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.search-group > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; cursor: pointer; background: var(--bg-secondary); }
.search-group > summary::-webkit-details-marker { display: none; }
.search-group-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.search-group-count { color: var(--secondary); font-size: .8rem; white-space: nowrap; }
.search-hits { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; }
.search-hit { position: relative; }
.search-hit-body { position: relative; display: flex; flex-direction: column; gap: .4rem; width: 100%; box-sizing: border-box; padding: .85rem 2.25rem .85rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.search-hit-body:hover { border-color: var(--primary); box-shadow: 0 1px 5px rgba(37, 99, 235, .12); }
.search-hit-body[aria-expanded="true"] { border-color: var(--primary); }
.search-hit-meta { display: flex; gap: .75rem; font-size: .75rem; color: var(--secondary); }
.search-hit-page { font-weight: 600; color: var(--primary); }
.search-hit-text { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }
.search-hit-chev { position: absolute; top: .9rem; right: 1rem; color: var(--secondary); font-size: .8rem; transition: transform .15s; }
.search-hit-body[aria-expanded="true"] .search-hit-chev { transform: rotate(180deg); }
.reader-slot { padding: 0 .25rem .25rem; }
.reader-slot:empty { display: none; }
.search-reader { position: relative; margin-top: .5rem; border: 1px solid var(--primary); border-radius: 8px; background: var(--bg); padding: .75rem; }
.search-reader-close { position: absolute; top: .4rem; right: .4rem; width: 1.5rem; height: 1.5rem; line-height: 1; border: none; border-radius: 4px; background: rgba(0, 0, 0, .05); color: var(--secondary); cursor: pointer; }
.search-reader-close:hover { background: rgba(0, 0, 0, .12); }
.search-reader-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.search-reader-scan { position: relative; line-height: 0; }
.search-reader-scan img { width: 100%; height: auto; display: block; border-radius: 6px; border: 1px solid var(--border); }
.search-reader-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.search-reader-box { fill: rgba(217, 119, 6, .18); stroke: #d97706; stroke-width: .005; vector-effect: non-scaling-stroke; }
.search-reader-text { min-width: 0; padding-right: 1.5rem; }
.search-reader-meta { margin: 0 0 .5rem; font-size: .75rem; color: var(--secondary); }
.search-reader-passage { margin: 0 0 .75rem; line-height: 1.6; overflow-wrap: anywhere; }
@media (max-width: 760px) { .search-reader-grid { grid-template-columns: 1fr; } }

/* Candidate triage badge (ADR 0003) — advisory "needs review" flag on
   recognition candidates. Amber like version-badge, but with the warning
   glyph so it reads as attention, not status. */
.needs-review-badge { display: inline-block; font-size: .68rem; color: #92400e; background: #fef3c7; border: 1px solid #fcd34d; border-radius: 1rem; padding: .05rem .45rem; margin-left: .35rem; cursor: help; }

/* Editorial marker toolbar (ADR 0002) — buttons, not syntax: nobody has to
   know the bracket conventions to use them. */
.marker-toolbar { display: flex; align-items: center; gap: .35rem; margin-top: .35rem; flex-wrap: wrap; }
.marker-toolbar-label { font-size: .72rem; color: var(--secondary); }
.marker-legend { position: relative; margin-left: auto; }
.marker-legend summary { list-style: none; cursor: help; width: 1.25rem; height: 1.25rem; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 50%; font-size: .72rem; color: var(--secondary); }
.marker-legend-panel { position: absolute; right: 0; top: 1.5rem; z-index: 30; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: .5rem; box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: .5rem .75rem; font-size: .75rem; min-width: 16rem; }
.marker-legend-panel p { margin: .2rem 0; }
.marker-legend-panel code { background: rgba(0,0,0,.05); border-radius: .25rem; padding: 0 .25rem; }
