@font-face {
  font-family: "Open Sans";
  src: url("/open-sans.ttf") format("truetype");
  font-weight: 300 800;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #213144;
  --muted: #536273;
  --blue: #0c66cc;
  --orange: #ed500d;
  --line: #dce3ec;
  --wash: #f6f8fb;
  font: 15px/1.5 "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f6f8fb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid #0c66cc; outline-offset: 3px; }
.top { background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 3px 12px #2131440c; }
.top-inner { max-width: 1360px; margin: auto; min-height: 76px; padding: 0 36px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-name { color: var(--ink); font-size: clamp(1.15rem, 2.4vw, 1.7rem); font-weight: 750; letter-spacing: -.045em; white-space: nowrap; }
.brand-name span { color: var(--orange); }
.brand-label { color: var(--muted); font-size: .86rem; }
.divider { height: 22px; width: 1px; background: var(--line); }
.connection { color: #254f7f; background: #eaf3ff; border: 1px solid #c9dff7; border-radius: 6px; padding: 5px 10px; font-size: .8rem; }
main { max-width: 1360px; margin: auto; padding: 35px 36px 50px; }
.intro { margin-bottom: 24px; }
.intro::after { content: ""; display: block; width: 54px; height: 3px; margin-top: 16px; background: var(--orange); border-radius: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.035em; line-height: 1.16; font-weight: 700; }
.intro p, .muted { color: var(--muted); }
.intro p { margin-top: 9px; font-size: 1.02rem; }
.notice { margin: 0 0 16px; padding: 10px 14px; border: 1px solid #d8dfaa; background: #f5f5de; border-radius: 8px; color: #505a29; font-size: .88rem; }
.workspace { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 6px #2131440d; }
.settings { padding: 20px; }
h2 { font-size: 1.15rem; letter-spacing: -.025em; }
h3 { font-size: .92rem; font-weight: 600; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; margin-top: 20px; }
.link { border: 0; background: transparent; color: var(--blue); padding: 5px 0; font-size: .83rem; font-weight: 600; }
.link:hover:not(:disabled) { text-decoration: underline; }
.categories { display: grid; gap: 4px; margin-top: 8px; max-height: 257px; overflow: auto; }
.categories label { display: flex; gap: 9px; align-items: center; padding: 5px 2px; font-size: .9rem; overflow-wrap: anywhere; }
.categories input { accent-color: var(--blue); margin: 0; width: 15px; height: 15px; flex: 0 0 auto; }
.rules { margin: 15px 0 18px; padding-top: 13px; border-top: 1px solid var(--line); }
.rules summary { cursor: pointer; font-size: .9rem; font-weight: 600; }
.rules textarea { min-height: 50px; padding: 7px; font-size: .82rem; }
.button { color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-weight: 600; }
.button:hover:not(:disabled) { background: #e0efff; border-color: #85aed9; }
.button.primary { background: var(--blue); color: white; border-color: var(--blue); }
.button.primary:hover:not(:disabled) { background: #09478f; }
.button.small { padding: 6px 10px; font-size: .82rem; }
#run { flex: 0 0 auto; }
#selection { margin-top: 7px; font-size: .8rem; }
.toolbar, .actions { display: flex; align-items: center; justify-content: space-between; padding: 13px 17px; gap: 10px; flex-wrap: wrap; }
.toolbar { border-bottom: 1px solid var(--line); }
.tabs, .button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { background: #f6f8fb; border-radius: 9px; padding: 3px; gap: 2px; }
.tab { border: 1px solid transparent; color: var(--muted); background: transparent; border-radius: 7px; padding: 5px 17px; font-weight: 600; }
.tab.active { background: white; color: var(--blue); border-color: #c5def7; }
.compare { display: grid; grid-template-columns: 1fr 1fr; padding: 15px 17px 0; gap: 12px; }
.pane { min-width: 0; background: #f7f9fc; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.pane.after { background: #edf5ff; }
.pane label { display: block; color: var(--muted); font-size: .8rem; letter-spacing: .055em; font-weight: 700; margin: 11px 13px 1px; }
textarea { display: block; width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); }
.pane textarea { box-sizing: border-box; padding: 8px 13px 12px; min-height: 230px; border: 0; background: transparent; border-radius: 0; }
.pane textarea:focus-visible { outline-offset: -3px; }
.actions { min-height: 64px; font-size: .83rem; }
.drop { display: grid; place-items: center; padding: 17px; margin: 14px 17px 0; border: 1px dashed #82a9d4; border-radius: 9px; cursor: pointer; background: #f0f6ff; text-align: center; }
.drop.drag { background: #e0efff; }
.drop span { font-size: .8rem; }
.queue { margin: 10px 17px 0; padding: 0; list-style: none;  }
.queue li { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 7px; font-size: .85rem; }
.queue .status { color: var(--muted); font-size: .8rem; }
.queue .error { color: #922d1f; }
@media (max-width: 850px) { main, .top-inner { padding-left: 19px; padding-right: 19px; } .workspace { grid-template-columns: minmax(0, 1fr); } .settings { order: 2; } .categories { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); } }
@media (max-width: 530px) { .compare { grid-template-columns: 1fr; } .pane textarea { min-height: 155px; } .top-inner { min-height: 58px; } .brand .divider, .brand-label { display: none; } }

.notice { white-space: pre-wrap; overflow-wrap: anywhere; }
.run-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 17px; background: #f6f8fb; border-bottom: 1px solid var(--line); }
.run-bar p { font-size: .85rem; }
.rules-help { margin: 7px 0 12px; font-size: .82rem; }
.rule-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0 0 9px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.rule-row label { display: grid; gap: 4px; color: var(--muted); font-size: .76rem; }
.rule-row button { grid-column: 1 / -1; justify-self: end; }
.queue li { padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; border-radius: 0; }
.queue-name { flex: 1 1 190px; min-width: 0; overflow-wrap: anywhere; }
.queue-name .status { display: block; }
.file-review { margin-top: 16px; border-top: 1px solid var(--line); }
.file-review h2 { overflow-wrap: anywhere; min-width: 0; }
.file-review > p { padding: 12px 17px 0; font-size: .86rem; }

.login { max-width: 450px; padding: 24px; }
.login p { margin-top: 6px; }
.login form { display: grid; gap: 8px; margin-top: 18px; }
.login label { font-size: .88rem; font-weight: 600; }
.login input { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; }
.login input + label { margin-top: 8px; }
.login form .button { margin-top: 10px; }

/* Inline comparison */
.preview-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin: 15px 17px 0; padding: 9px 12px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 9px; }
.preview-caption, .preview-navigation { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .82rem; }
.preview-navigation .button { min-width: 34px; }
.preview-navigation span { min-width: 66px; text-align: center; font-variant-numeric: tabular-nums; }
.preview-text { height: clamp(245px, 40vh, 410px); overflow: auto; margin: 0; padding: 12px 15px 18px; background: #fff; font: inherit; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
[data-category] { --facet-bg: #e9eef2; --facet-ink: #344759; --facet-line: #6c8496; }
[data-category="people"] { --facet-bg: #eee5fb; --facet-ink: #532787; --facet-line: #8860bb; }
[data-category="documents"] { --facet-bg: #e0ebfb; --facet-ink: #20487c; --facet-line: #5d84bf; }
[data-category="dates"] { --facet-bg: #fce9d9; --facet-ink: #813c17; --facet-line: #b77544; }
[data-category="addresses"] { --facet-bg: #def3e7; --facet-ink: #195839; --facet-line: #549775; }
[data-category="contacts"] { --facet-bg: #daf0f5; --facet-ink: #155464; --facet-line: #538fa0; }
[data-category="finance"] { --facet-bg: #faefcc; --facet-ink: #6c4e10; --facet-line: #a38743; }
[data-category="organizations"] { --facet-bg: #f8e3ed; --facet-ink: #742d4e; --facet-line: #aa647f; }
[data-category="technical"] { --facet-bg: #e4e7fa; --facet-ink: #353e84; --facet-line: #727bbb; }
.preview-text mark, .replacement-token { background: var(--facet-bg); color: var(--facet-ink); border-radius: 3px; }
.preview-text mark { box-shadow: inset 0 -2px var(--facet-line); cursor: pointer; }
.after .preview-text mark, .replacement-token { box-shadow: inset 0 0 0 1px var(--facet-line); padding: 1px 3px; }
.preview-text .active-change { outline: 2px solid var(--facet-ink); outline-offset: 1px; }
.preview-text .empty-change { display: inline-block; width: 3px; height: 1em; vertical-align: middle; background: currentColor; }
.preview-caption { color: var(--muted); font-weight: 600; }
.compare.with-replacements { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(190px, .78fr); }
.replacement-panel { background: #fff; }
.replacement-panel h3 { margin: 11px 13px 5px; font-size: .85rem; }
.replacement-groups { height: clamp(245px, 40vh, 410px); overflow: auto; padding: 7px 12px 12px; }
.replacement-groups h4 { margin: 4px 0; color: var(--facet-ink); font-size: .76rem; font-weight: 700; }
.replacement-groups h4::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--facet-line); }
.replacement-groups ul { list-style: none; margin: 0 0 12px; padding: 0; }
.replacement-groups li + li { border-top: 1px solid var(--line); }
.replacement-row { width: 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 7px; border: 0; border-radius: 4px; background: transparent; padding: 6px 4px; text-align: left; font: inherit; font-size: .82rem; color: var(--ink); overflow-wrap: anywhere; }
.replacement-row:hover, .replacement-row[aria-current="true"] { background: #edf4fc; }
.replacement-row[aria-current="true"] { box-shadow: inset 2px 0 var(--facet-line); }
.replacement-token { font: .78rem/1.4 ui-monospace, monospace; white-space: pre-wrap; }
.replacement-source { white-space: pre-wrap; }
.replacement-count { color: var(--muted); margin-left: auto; }
@media (max-width: 1100px) {
  .compare.with-replacements { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .replacement-panel { grid-column: 1 / -1; }
  .replacement-groups { height: auto; max-height: 280px; }
}
@media (max-width: 530px) {
  .compare.with-replacements { grid-template-columns: minmax(0, 1fr); }
}

/* Give the comparison the full workspace while the preview is open. */
main:has(.with-replacements) { max-width: 1680px; }
.workspace:has(.with-replacements) { grid-template-columns: minmax(0, 1fr); }
.workspace:has(.with-replacements) > .settings { order: 2; }
@media (min-width: 1101px) {
  .compare.with-replacements { grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(200px, 22%); }
}

.categories { max-height: 390px; gap: 8px; }
.category-group { min-width: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.category-heading { display: flex; align-items: center; gap: 4px; padding-left: 8px; background: var(--facet-bg); color: var(--facet-ink); }
.category-toggle { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px 7px 5px; border: 0; background: transparent; color: inherit; font: inherit; font-size: .9rem; font-weight: 700; text-align: left; }
.category-toggle:focus-visible { outline-offset: -3px; }
.category-toggle::after { content: ""; width: 6px; height: 6px; margin-right: 3px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.category-toggle[aria-expanded="true"]::after { transform: rotate(225deg); }
.category-fields { padding: 3px 8px 4px 18px; }
.category-fields label { font-size: .83rem; }

.compare.source-only { grid-template-columns: minmax(0, 1fr); }
.pdf-nav { margin-top: 8px; }
.pdf-pane { padding: 12px; overflow: auto; max-height: 72vh; }
.pdf-pane h3 { margin-bottom: 8px; }
.pdf-pane img { display: block; width: 100%; height: auto; background: #fff; }
.pdf-pane p { padding: 8px 0; }

.notice-empty { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }

.field-caption { display: flex; align-items: center; gap: 7px; min-width: 0; }
.login .field-caption + input { margin-bottom: 6px; }
.pane .field-caption { margin: 11px 13px 1px; }
.pane .field-caption label { margin: 0; }
.field-help { display: inline-grid; place-items: center; position: relative; flex: 0 0 auto; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 50%; color: var(--blue); background: white; font-size: .77rem; font-weight: 700; cursor: help; }
.field-tooltip { position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; width: min(220px, 56vw); padding: 8px 10px; border-radius: 6px; background: var(--ink); color: white; visibility: hidden; opacity: 0; font-weight: 400; line-height: 1.45; }
.field-help:hover .field-tooltip, .field-help:focus .field-tooltip { visibility: visible; opacity: 1; }
.field-tooltip::before { content: ""; position: absolute; inset: -5px 0 100%; }
.pane:has(.field-help) { overflow: visible; }
@media (max-width: 420px) {
  .settings .field-tooltip, .pane .field-tooltip { left: auto; right: 0; }
}
.field-help.tooltip-dismissed .field-tooltip { visibility: hidden; opacity: 0; }

.result-edit { display: grid; gap: 7px; padding: 9px 12px 12px; border-top: 1px solid var(--line); }
.result-edit label { margin: 0; letter-spacing: normal; }
.result-edit textarea { min-height: 48px; border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; font-size: .85rem; }
.result-edit .button { justify-self: start; }
