:root {
    --ink: #1c1e21;
    --muted: #5a5f66;
    --line: #e3e2dc;
    --bg: #fafaf7;
    --surface: #ffffff;
    --accent: #2456a6;
    --ok-bg: #e5f2e8;   --ok-ink: #2e7d46;
    --warn-bg: #fbeedc; --warn-ink: #9a5b00;
    --bad-bg: #f9e5e3;  --bad-ink: #b3372f;
    --info-bg: #e3edf7; --info-ink: #2b6cb0;
    --dim-bg: #ecedef;  --dim-ink: #5b6270;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.55 system-ui, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 2rem;
    padding: 0.7rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.topbar nav { display: flex; gap: 1.2rem; }
.topbar .logout { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; }
.topbar .logout button { padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--ink); }

.content { flex: 1; padding: 1.5rem; max-width: 1180px; width: 100%; margin: 0 auto; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.8rem 0 0.6rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.1rem 1.3rem;
    margin-bottom: 1rem;
}

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th {
    text-align: left; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--muted);
    border-bottom: 1.5px solid var(--line); padding: 0.4rem 0.8rem 0.4rem 0;
    white-space: nowrap;
}
td { border-bottom: 1px solid var(--line); padding: 0.5rem 0.8rem 0.5rem 0; vertical-align: top; }
tr:hover td { background: #00000006; }

.chip {
    display: inline-block; font-size: 0.74rem; font-weight: 600;
    padding: 0.22em 0.6em; border-radius: 999px; white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); }
.chip.info { background: var(--info-bg); color: var(--info-ink); }
.chip.dim { background: var(--dim-bg); color: var(--dim-ink); }
/* error category of a corrector's edit (free text — may get long) */
.chip.cat {
    background: #f3e8ff; color: #6d28d9;
    max-width: 11rem; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
}
/* in the corrector's sidebar the badge doubles as the category editor */
.chip.cat.editable { cursor: pointer; }
.chip.cat.editable:hover { outline: 1px solid #6d28d9; }

button, .button {
    font: inherit; padding: 0.45rem 1rem; border-radius: 6px;
    border: 1px solid var(--accent); background: var(--accent); color: white;
    cursor: pointer; text-decoration: none; display: inline-block;
}
button.secondary, .button.secondary {
    background: var(--surface); color: var(--accent);
}
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

input[type=text], input[type=number], input[type=search], select {
    font: inherit; padding: 0.4rem 0.6rem;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--surface); color: var(--ink);
    width: 100%; max-width: 26rem;
}
label { display: block; font-weight: 600; margin: 0.8rem 0 0.25rem; }
.hint { color: var(--muted); font-size: 0.82rem; }

.filegrid { display: flex; gap: 1rem; flex-wrap: wrap; }
.downloads { display: flex; gap: 0.7rem; flex-wrap: wrap; margin: 0.6rem 0; }

.statgrid { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.stat { min-width: 7rem; }
.stat .n { font-size: 1.5rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 0.8rem; }

.error { background: var(--bad-bg); color: var(--bad-ink); padding: 0.7rem 1rem; border-radius: 6px; }
.notice { background: var(--info-bg); color: var(--info-ink); padding: 0.7rem 1rem; border-radius: 6px; }

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.85em; }
.muted { color: var(--muted); }

/* corrector-facing review page */
.review-shell { display: flex; flex-direction: column; height: 100vh; position: relative; }
.review-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.6rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.review-main { flex: 1; display: flex; min-height: 0; }
.bar-toggle {
    display: flex; align-items: center; gap: 0.35rem;
    font-size: 0.85rem; color: var(--muted); cursor: pointer; user-select: none;
}
.bar-toggle input { width: auto; cursor: pointer; }
.review-sidebar {
    width: 20rem; flex-shrink: 0; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line); padding: 1rem;
}
.review-sidebar h2 { margin: 0 0 0.3rem; font-size: 1rem; }
.review-pages { flex: 1; overflow: auto; padding: 12px; background: #8a8d92; position: relative; }
/* read-only list of the comments that came with the PDF (customer, PM…) */
.review-doc-comments {
    width: 19rem; flex-shrink: 0; overflow-y: auto;
    background: var(--surface); border-left: 1px solid var(--line); padding: 1rem;
}
.review-doc-comments h2 { margin: 0 0 0.3rem; font-size: 1rem; }
.review-doc-comments .annotation-item { cursor: pointer; }
/* click-in-PDF navigation target — both the own-changes sidebar and the
   embedded-comments panel use the same marking */
.annotation-item.active { background: var(--info-bg); }
.annotation-item.flash { animation: item-flash 1.5s ease-out; }
@keyframes item-flash {
    0% { background: rgba(255, 200, 0, 0.55); }
    100% { background: var(--info-bg); }
}

/* transient bubble over a clicked embedded annotation — anchored above its rect
   so the text underneath stays free for selection */
.doc-comment-bubble {
    position: absolute; z-index: 40; width: 270px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25); padding: 0.5rem 1.6rem 0.5rem 0.7rem;
    font-size: 0.84rem; line-height: 1.4;
}
.doc-comment-bubble .bubble-entry { cursor: pointer; border-radius: 4px; padding: 0.1rem 0.2rem; }
.doc-comment-bubble .bubble-entry:hover { background: var(--dim-bg); }
.doc-comment-bubble .bubble-entry + .bubble-entry {
    border-top: 1px solid var(--line); margin-top: 0.4rem; padding-top: 0.4rem;
}
.doc-comment-bubble .bubble-text { overflow-wrap: anywhere; }
.doc-comment-bubble .bubble-close {
    position: absolute; top: 0.25rem; right: 0.35rem;
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 1rem; padding: 0 0.2rem;
}
.doc-comment-bubble .bubble-close:hover { color: var(--ink); }

.pdf-page {
    position: relative; margin: 0 auto 12px; background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.pdf-page canvas { display: block; }

/* pdf.js text layer: transparent selectable text positioned over the canvas */
.textLayer {
    position: absolute; inset: 0; overflow: hidden;
    line-height: 1; forced-color-adjust: none; text-size-adjust: none; caret-color: transparent;
}
.textLayer span, .textLayer br {
    position: absolute; color: transparent; white-space: pre;
    cursor: text; transform-origin: 0% 0%;
}
.textLayer ::selection { background: rgba(36, 86, 166, 0.35); }

.highlight-overlay { position: absolute; inset: 0; pointer-events: none; }
.highlight { position: absolute; border-radius: 2px; }
.highlight.replace { background: rgba(48, 176, 105, 0.30); }
.highlight.insert_after { background: rgba(36, 86, 166, 0.25); }
.highlight.delete { background: rgba(214, 69, 56, 0.30); text-decoration: line-through; }
.highlight.comment { background: rgba(240, 173, 40, 0.35); }

.selection-menu {
    display: none; position: absolute; z-index: 30; min-width: 15rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18); padding: 0.4rem;
}
.selection-menu.open { display: block; }
.selection-menu > button {
    display: block; width: 100%; text-align: left; margin: 0.15rem 0;
    background: var(--surface); color: var(--ink); border: 0; padding: 0.45rem 0.7rem;
    border-radius: 6px;
}
.selection-menu > button:hover { background: var(--dim-bg); }
.menu-input { padding: 0.4rem 0.7rem 0.5rem; border-top: 1px solid var(--line); margin-top: 0.3rem; }
.menu-input label { font-size: 0.8rem; margin: 0 0 0.25rem; }
.menu-input input { max-width: 100%; margin-bottom: 0.4rem; }

/* the picked edit kind while its category submenu is open */
.selection-menu > button.active { background: var(--info-bg); }
/* category submenu: flies out beside the picked action, configured list + free text at the bottom */
.menu-cats {
    position: absolute; left: calc(100% + 4px); top: 0; min-width: 12rem; z-index: 40;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    padding: 0.4rem 0.3rem 0.2rem; max-height: 24rem; overflow-y: auto;
}
.menu-cats.flip { left: auto; right: calc(100% + 4px); }
.menu-cats > label { font-size: 0.8rem; margin: 0 0.4rem 0.25rem; color: var(--muted); }
.menu-cats > button {
    display: block; width: 100%; text-align: left; margin: 0.1rem 0;
    background: var(--surface); color: var(--ink); border: 0;
    padding: 0.35rem 0.7rem; border-radius: 6px; font-size: 0.88rem;
}
.menu-cats > button:hover { background: var(--dim-bg); }
.menu-cats-custom { display: flex; gap: 0.35rem; padding: 0.3rem 0.4rem 0.35rem; border-top: 1px dashed var(--line); margin-top: 0.25rem; }
.menu-cats-custom input { flex: 1; min-width: 0; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.menu-cats-custom button { padding: 0.3rem 0.7rem; }

.annotation-item {
    border-bottom: 1px solid var(--line); padding: 0.6rem 0.4rem; font-size: 0.88rem;
    cursor: pointer; border-radius: 6px;
    position: relative;   /* anchors the sidebar category picker */
}
.annotation-item:hover { background: var(--dim-bg); }

/* focus ring pulsed around an annotation's quads after sidebar navigation */
.highlight-focus {
    position: absolute; pointer-events: none; z-index: 5;
    border: 2px solid var(--accent); border-radius: 4px;
    box-shadow: 0 0 0 4px rgba(36, 86, 166, 0.25);
    animation: focus-pulse 0.85s ease-in-out 3;
}
@keyframes focus-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}
@media (prefers-reduced-motion: reduce) {
    .highlight-focus { animation: none; }
}
.annotation-summary { margin: 0.25rem 0; overflow-wrap: anywhere; }
.link-button {
    background: none; border: none; color: var(--accent); padding: 0;
    font-size: 0.8rem; cursor: pointer; text-decoration: underline;
}

/* operator-facing verification page (three synchronized panels) */
.verify-shell { display: flex; flex-direction: column; height: 100vh; }
/* overflow-x is the last resort for windows smaller than the panel minimums —
   normally fitPanels() in verify.js shrinks the side panels to keep everything visible */
.verify-main { flex: 1; display: flex; min-height: 0; overflow-x: auto; }
.verify-queue {
    width: 21rem; flex-shrink: 0; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line); padding: 0.8rem;
}
.verify-pages { flex: 1; overflow: auto; padding: 12px; background: #8a8d92; position: relative; }
.verify-segments {
    width: 27rem; flex-shrink: 0; overflow-y: auto;
    background: var(--surface); border-left: 1px solid var(--line); padding: 0.8rem 1rem;
}

/* draggable splitters between the verify panels (widths persist per browser) */
.verify-splitter {
    width: 5px; flex-shrink: 0; cursor: col-resize;
    background: var(--line); transition: background 0.15s;
}
.verify-splitter:hover, .verify-splitter.dragging { background: var(--accent); }
body.panel-resizing { cursor: col-resize; user-select: none; }
body.panel-resizing .textLayer { pointer-events: none; }

/* read-only export context list (rightmost panel) */
.verify-export {
    width: 24rem; flex-shrink: 0; display: flex; flex-direction: column;
    background: var(--surface); border-left: 1px solid var(--line);
}
.verify-export-head {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line);
}
.verify-export-head input[type=number] { max-width: 6rem; padding: 0.2rem 0.4rem; }
.verify-export-list { flex: 1; overflow-y: auto; }
.export-row {
    display: grid; grid-template-columns: 3.4rem 1fr 1fr 1fr; gap: 0.5rem;
    height: 24px; line-height: 24px; padding: 0 0.6rem;
    font-size: 0.76rem; white-space: nowrap; cursor: pointer;
    border-bottom: 1px solid #00000008;
}
.export-row > span { overflow: hidden; text-overflow: ellipsis; }
.export-row > .n { color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
/* the would-be-applied text — visually set off from the current target */
.export-row > .new { color: var(--accent); }
/* space saver: each of the three text columns hides on demand */
.verify-export-list.cols-2 .export-row { grid-template-columns: 3.4rem 1fr 1fr; }
.verify-export-list.cols-1 .export-row { grid-template-columns: 3.4rem 1fr; }
.verify-export-list.cols-0 .export-row { grid-template-columns: 3.4rem; }
.verify-export-list.hide-src .export-row > .src { display: none; }
.verify-export-list.hide-old .export-row > .old { display: none; }
.verify-export-list.hide-new .export-row > .new { display: none; }
/* row whose text could not be located in the PDF — the viewer cannot navigate to it */
.export-row.unmapped { background: rgba(214, 69, 56, 0.06); }
.export-row.unmapped > .n { color: var(--bad-ink); }
.export-row.search-hit { background: rgba(255, 200, 0, 0.14); }
.export-row:hover { background: var(--dim-bg); }
.export-row.selected { background: var(--info-bg); }
/* the current find match outranks even the open-segment tint */
.export-row.search-current { background: rgba(255, 200, 0, 0.45); }
.export-row.touched > .n { color: var(--accent); font-weight: 700; }

/* floating "copy selection" chip over the verification PDF */
.copy-chip {
    position: fixed; z-index: 60;
    /* it's a <button>, so undo the global white-on-accent text color */
    background: var(--surface, #fff); color: var(--ink); border: 1px solid var(--line, #ccc); border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    padding: 0.2rem 0.6rem; font-size: 0.8rem; cursor: pointer; user-select: none;
}
.copy-chip:hover { background: var(--dim-bg, #f2f2f2); }
.copy-chip.done { color: var(--accent); cursor: default; }

/* find box of the export list */
.verify-export-search {
    display: flex; align-items: center; gap: 0.3rem;
    padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--line);
}
.verify-export-search input { flex: 1; min-width: 0; max-width: none; padding: 0.25rem 0.5rem; font-size: 0.85rem; }
.verify-export-search .hint { min-width: 3rem; text-align: center; }

.queue-item {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 0.55rem 0.7rem; margin-bottom: 0.5rem; font-size: 0.88rem;
    cursor: pointer; background: var(--surface);
}
.queue-item:hover { background: var(--dim-bg); }
.queue-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(36, 86, 166, 0.18); }
.queue-item .queue-change { overflow-wrap: anywhere; margin: 0.2rem 0; }
.queue-item .queue-actions { margin-top: 0.45rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.queue-item .queue-actions button { padding: 0.25rem 0.7rem; font-size: 0.82rem; }
/* inline re-categorize control of a selected queue item */
.queue-item .queue-cat-edit { margin-top: 0.4rem; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.queue-item .queue-cat-edit select { width: auto; max-width: 12rem; padding: 0.15rem 0.35rem; font-size: 0.8rem; }
.queue-item .queue-cat-edit input { width: 9rem; max-width: 9rem; padding: 0.15rem 0.4rem; font-size: 0.8rem; }
.queue-item .queue-cat-edit button { padding: 0.15rem 0.55rem; font-size: 0.8rem; }
.queue-section {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted); margin: 1rem 0 0.4rem;
}

.segment-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line);
    font-size: 0.85rem; cursor: pointer; border-radius: 4px;
}
.segment-row:hover { background: var(--dim-bg); }
.segment-row.selected { background: var(--info-bg); }
.segment-row .row-buttons { margin-left: auto; display: flex; gap: 0.3rem; }
.segment-row .row-buttons button { padding: 0.1rem 0.5rem; font-size: 0.75rem; }

.preview-box {
    border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.7rem;
    font-size: 0.9rem; background: var(--bg); overflow-wrap: anywhere; white-space: pre-wrap;
}
mark.contrib { border-radius: 3px; padding: 0 1px; cursor: pointer; }
mark.contrib-0 { background: rgba(48, 176, 105, 0.35); }
mark.contrib-1 { background: rgba(36, 86, 166, 0.28); color: inherit; }
mark.contrib-2 { background: rgba(240, 173, 40, 0.40); }
mark.contrib-3 { background: rgba(186, 85, 211, 0.30); }
mark.contrib-4 { background: rgba(214, 69, 56, 0.30); }
.contrib-dot {
    display: inline-block; width: 0.7em; height: 0.7em; border-radius: 3px;
    margin-right: 0.35em; vertical-align: baseline;
}
.contrib-dot.contrib-0 { background: rgba(48, 176, 105, 0.55); }
.contrib-dot.contrib-1 { background: rgba(36, 86, 166, 0.45); }
.contrib-dot.contrib-2 { background: rgba(240, 173, 40, 0.60); }
.contrib-dot.contrib-3 { background: rgba(186, 85, 211, 0.45); }
.contrib-dot.contrib-4 { background: rgba(214, 69, 56, 0.45); }
.contrib-item { cursor: pointer; padding: 0.15rem 0.2rem; border-radius: 4px; font-size: 0.84rem; }
.contrib-item:hover { background: var(--dim-bg); }

.verify-segments textarea {
    font: inherit; font-size: 0.9rem; width: 100%; min-height: 5.5rem;
    border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.7rem;
    background: var(--surface); color: var(--ink); resize: vertical;
}
.highlight.verify-mark { background: rgba(36, 86, 166, 0.28); }
/* segment→PDF text occurrence (reverse navigation) — teal, dashed: "the text
   lives here", as opposed to the blue anchored review-comment marks */
.highlight.text-match {
    background: rgba(23, 162, 184, 0.22);
    outline: 1.5px dashed rgba(23, 162, 184, 0.75);
    outline-offset: 1px;
}

/* find bar (Acrobat-style, shared by both PDF views) — floats over the pages,
   pinned to the top of the scrolling panel without shifting the layout */
.pdf-find-wrap {
    position: sticky; top: 0; height: 0; overflow: visible; z-index: 25;
    display: flex; justify-content: flex-end;
}
.pdf-find-bar {
    display: flex; align-items: center; gap: 0.35rem;
    margin: 6px 18px 0 0; padding: 0.35rem 0.5rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.pdf-find-bar input { width: 13rem; padding: 0.25rem 0.5rem; font-size: 0.85rem; }
.pdf-find-bar button {
    padding: 0.15rem 0.55rem; font-size: 0.85rem;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.pdf-find-bar button:hover { background: var(--dim-bg); }
.pdf-find-count { font-size: 0.78rem; color: var(--muted); min-width: 4rem; text-align: center; white-space: nowrap; }
.highlight.find-current {
    background: rgba(255, 200, 0, 0.45);
    outline: 2px solid rgba(232, 150, 0, 0.9);
}

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--warn-bg); color: var(--warn-ink); padding: 0.6rem 1.2rem;
}
