/* PDF Redactor: self-hosted styles, system fonts only (the CSP forbids external loads). */
:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --well: #ececef;
  --border: #e4e4e8;
  --border-strong: #d0d0d6;
  --text: #17171c;
  --muted: #61616b;
  --faint: #9a9aa3;
  --accent: #5b5bd6;
  --accent-hover: #4c4cc4;
  --accent-solid: #5b5bd6;
  --accent-solid-hover: #4c4cc4;
  --accent-soft: rgba(91, 91, 214, .10);
  --accent-ring: rgba(91, 91, 214, .35);
  --on-accent: #ffffff;
  --success: #15803d;
  --success-hover: #116c33;
  --success-solid: #15803d;
  --success-solid-hover: #116c33;
  --success-soft: #ecfdf3;
  --success-border: #b7ebc9;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --disabled-bg: #ececef;
  --disabled-text: #9a9aa3;
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .06);
  --shadow: 0 1px 2px rgba(16, 16, 24, .05), 0 4px 16px rgba(16, 16, 24, .06);
  --shadow-page: 0 1px 3px rgba(16, 16, 24, .10), 0 8px 24px rgba(16, 16, 24, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
/* Theme: light by default (system setting ignored); the header switch sets data-theme="light" or "dark". */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e11;
  --surface: #17171b;
  --surface-2: #1f1f24;
  --well: #121215;
  --border: #2a2a31;
  --border-strong: #3a3a43;
  --text: #ececf1;
  --muted: #a0a0ab;
  --faint: #6c6c76;
  --accent: #7c7cf0;
  --accent-hover: #8f8ff5;
  --accent-solid: #5858d4;
  --accent-solid-hover: #6767de;
  --accent-soft: rgba(124, 124, 240, .14);
  --accent-ring: rgba(124, 124, 240, .45);
  --on-accent: #ffffff;
  --success: #3ccb72;
  --success-solid: #178a43;
  --success-solid-hover: #1c9a4c;
  --success-soft: rgba(34, 167, 85, .12);
  --success-border: rgba(34, 167, 85, .35);
  --danger: #f97066;
  --danger-soft: rgba(240, 68, 56, .12);
  --danger-border: rgba(240, 68, 56, .35);
  --disabled-bg: #26262c;
  --disabled-text: #6c6c76;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-page: 0 2px 6px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  /* Fill the viewport: header, content, footer in one column; the footer sits at the bottom. */
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
body > * { flex: none; }
.wrap { width: 100%; }
body > main:not([hidden]) { flex: 1 0 auto; }
/* Landing (no document open): sit the hero and drop zone a little above centre (the visible gaps above the heading and below the drop zone split about 40:60) between
   header and footer, using two flex spacers weighted 1:3 (header pulled before the top spacer,
   footer pushed after the bottom one). */
body:not(:has(#review:not([hidden])))::before,
body:not(:has(#review:not([hidden])))::after { content: ""; display: block; min-height: 0; }
body:not(:has(#review:not([hidden])))::before { flex: 1 1 0; }
body:not(:has(#review:not([hidden])))::after { flex: 3 1 0; }
body:not(:has(#review:not([hidden]))) > .topbar { order: -1; }
body:not(:has(#review:not([hidden]))) > footer { order: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1320px; margin: 0 auto; padding-left: 32px; padding-right: 32px; }

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 20px; letter-spacing: -.015em; }
.logo { width: 32px; height: 32px; fill: var(--accent); }
.logo .ink { fill: var(--on-accent); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted);
  cursor: pointer; box-shadow: none;
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Hero */
.hero { padding-top: 40px; padding-bottom: 24px; text-align: center; }
.hero h1 {
  margin: 0 auto 12px; max-width: 760px; font-size: clamp(30px, 5vw, 52px); line-height: 1.1;
  font-weight: 700; letter-spacing: -.018em; word-spacing: .04em; text-wrap: balance;
}
.hero .lead { margin: 0 auto 18px; max-width: 640px; font-size: 17px; line-height: 1.45; color: var(--muted); text-wrap: balance; }
body:has(#review:not([hidden])) .hero .lead { display: none; }

.private {
  display: inline-flex; align-items: center; gap: 10px; margin: 6px 0 0; padding: 9px 16px; border-radius: 12px;
  font-size: 14.5px; color: var(--text); background: var(--success-soft); border: 1px solid var(--success-border, var(--success-soft));
  text-align: left;
}
.private svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--success); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.private strong { font-weight: 650; color: var(--success); }
body:has(#review:not([hidden])) .private { margin-top: 4px; padding: 5px 12px; font-size: 13px; }

/* Drop zone */
.drop {
  margin: 8px auto 16px; max-width: 800px; padding: 44px 40px 36px; text-align: center;
  background: var(--surface); border: 1.5px dashed var(--border-strong); border-radius: 16px;
  box-shadow: var(--shadow-sm); transition: border-color .15s, background .15s, box-shadow .15s;
}
.drop:hover { border-color: var(--accent); }
.drop:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.drop.over { border-color: var(--accent); border-style: solid; background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-ring); }
.drop-icon {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.drop-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop-title { margin: 0; font-size: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.drop-title strong { font-weight: 650; letter-spacing: -.01em; }
.drop-title .or { color: var(--muted); }
.pick {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  background: var(--accent-solid); color: var(--on-accent); font-size: 14.5px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .12); transition: background .15s;
}
.pick:hover { background: var(--accent-solid-hover); }
.pick:focus-within { box-shadow: 0 0 0 4px var(--accent-ring); }
.names { margin: 24px auto 0; max-width: 480px; padding-top: 20px; border-top: 1px solid var(--border); text-align: left; }
.names label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 550; color: var(--text); }
.names em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type="text"] {
  font: inherit; font-size: 14px; width: 100%; height: 38px; padding: 0 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]::placeholder { color: var(--faint); }
input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* Once a document is open, the hero and drop zone shrink so the review gets the room. */
body:has(#review:not([hidden])) .hero { padding-top: 24px; padding-bottom: 12px; }
body:has(#review:not([hidden])) .hero h1 { font-size: 22px; margin-bottom: 4px; }
body:has(#review:not([hidden])) .drop {
  max-width: none; padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; text-align: left;
}
body:has(#review:not([hidden])) .drop-icon { width: 36px; height: 36px; margin: 0; border-radius: 10px; }
body:has(#review:not([hidden])) .drop-icon svg { width: 18px; height: 18px; }
body:has(#review:not([hidden])) .drop-title { font-size: 15px; justify-content: flex-start; }
body:has(#review:not([hidden])) .pick { height: 32px; padding: 0 12px; font-size: 13.5px; }
body:has(#review:not([hidden])) .names { margin: 0 0 0 auto; padding: 0; border: 0; flex: 1 1 300px; max-width: 420px; }
body:has(#review:not([hidden])) .names label { flex-direction: row; align-items: center; gap: 10px; white-space: nowrap; }
body:has(#review:not([hidden])) .names em { display: none; }
body:has(#review:not([hidden])) .names input { height: 32px; }

/* Progress: full content width (same as the drop zone), status line above a thick accent bar */
#progress { max-width: 800px; margin: 0 auto 24px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
#progress[hidden] { display: none; }
body:has(#review:not([hidden])) #progress { max-width: none; margin-bottom: 16px; }
.ptop { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
#ptext { color: var(--text); font-weight: 550; }
#ppct { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.bar { position: relative; width: 100%; height: 8px; background: var(--well); border: 0; border-radius: 999px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.bar span { position: relative; display: block; height: 100%; width: 0; min-width: 8px; background: var(--accent); border-radius: 999px; overflow: hidden; transition: width .3s ease, background-color .3s ease; }
#progress[data-state="working"] .bar span::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .45) 50%, transparent 100%);
  background-size: 200px 100%; background-repeat: no-repeat;
  animation: bar-shimmer 1.3s linear infinite;
}
@keyframes bar-shimmer { from { background-position: -200px 0; } to { background-position: calc(100% + 200px) 0; } }
#progress[data-state="done"] .bar span { background: var(--success); }
#progress[data-state="done"] #ptext { color: var(--success); }
#progress[data-state="fail"] .bar span { background: var(--danger); }
#progress[data-state="fail"] #ptext { color: var(--danger); }
@media (prefers-reduced-motion: reduce) {
  .bar span { transition: none; }
  #progress[data-state="working"] .bar span::after { animation: none; display: none; }
}


/* Review layout */
main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; padding-bottom: 32px; }
main[hidden] { display: none; }
.pages {
  display: flex; flex-direction: column; gap: 24px; align-items: center; padding: 28px;
  background: var(--well); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto;
}
.page { position: relative; flex: none; background: #fff; border-radius: 2px; box-shadow: var(--shadow-page); user-select: none; cursor: crosshair; }
.page canvas { display: block; border-radius: 2px; }
.viewer { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.review-hint {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 9px 14px;
  font-size: 13.5px; line-height: 1.4; color: var(--muted);
  background: var(--accent-soft); border: 1px solid var(--accent-ring); border-radius: var(--radius-sm);
}
.review-hint strong { color: var(--text); font-weight: 600; }
.review-hint svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Boxes sit on the white page in both themes, so their colours are fixed rather than themed. */
.box { position: absolute; border: 2px solid #5b5bd6; background: rgba(91, 91, 214, .16); border-radius: 2px; cursor: pointer; transition: background .12s, box-shadow .12s, transform .12s; }
.box:hover { z-index: 2; background: rgba(91, 91, 214, .30); box-shadow: 0 0 0 3px rgba(91, 91, 214, .30), 0 4px 10px rgba(16, 16, 24, .18); transform: translateY(-1px); }
.box.manual { border-style: dashed; border-color: #c2410c; background: rgba(234, 88, 12, .14); }
.box.manual:hover { background: rgba(234, 88, 12, .26); box-shadow: 0 0 0 3px rgba(234, 88, 12, .28), 0 4px 10px rgba(16, 16, 24, .18); }
.box.off { border: 1.5px dashed #8a8a93; background: transparent; }
.box.off:hover { border-color: #5b5bd6; background: rgba(91, 91, 214, .06); box-shadow: 0 0 0 3px rgba(91, 91, 214, .18); }
.box::after {
  content: "\00d7  Click to unredact"; position: absolute; right: -2px; bottom: calc(100% + 6px);
  padding: 3px 8px; white-space: pre; pointer-events: none;
  font: 600 11.5px/1.3 var(--font); color: #ffffff; background: #17171c; border-radius: 6px;
  box-shadow: 0 2px 8px rgba(16, 16, 24, .25); opacity: 0; transform: translateY(2px); transition: opacity .12s, transform .12s;
}
.box.off::after { content: "+  Click to redact again"; background: #5b5bd6; }
.box:hover::after { opacity: 1; transform: none; }
.box.flash { outline: 3px solid #f5a623; outline-offset: 2px; }
.drag { position: absolute; border: 2px dashed #c2410c; background: rgba(234, 88, 12, .12); border-radius: 2px; pointer-events: none; }

/* Side panel */
.panel {
  position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Buttons */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; transition: background .15s, box-shadow .15s, color .15s;
  background: var(--surface-2); color: var(--text);
}
.btn.primary { background: var(--accent-solid); color: var(--on-accent); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover:not(:disabled) { background: var(--accent-solid-hover); }
.btn.success { background: var(--success-solid); color: #fff; box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.success:hover:not(:disabled) { background: var(--success-solid-hover); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
button:disabled, .btn:disabled {
  background: var(--disabled-bg); color: var(--disabled-text); border-color: var(--border); box-shadow: none; cursor: not-allowed;
}

/* Toggle switch (Reveal values) */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--accent-solid); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-ring); }

/* Status */
.status { margin: 12px 0 0; padding: 10px 12px; font-size: 13px; line-height: 1.45; border-radius: var(--radius-sm); color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.status:empty { display: none; }
.status.pass { color: var(--success); background: var(--success-soft); border-color: var(--success-border); font-weight: 500; }
.status.fail { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); font-weight: 500; }
.status ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }

.small { color: var(--muted); font-size: 12.5px; margin: 4px 0; }
.total { margin: 14px 0 6px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; }
.total strong { color: var(--text); font-weight: 650; }

/* Summary: category groups and item chips */
.cat { margin-top: 14px; }
.cat h3 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.count {
  min-width: 22px; height: 20px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 999px;
  font-size: 11.5px; letter-spacing: 0; color: var(--accent); background: var(--accent-soft);
}
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0; padding: 7px 10px;
  font-size: 13px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.item .val { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.item .val::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.item .pg { flex: none; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item:hover { border-color: var(--accent); background: var(--accent-soft); }
.item.off { color: var(--faint); background: transparent; border-style: dashed; }
.item.off .val { text-decoration: line-through; }
.item.off .val::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.notes:not(:empty) { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Footer */
footer p { margin: 0 0 4px; }
footer { padding-top: 20px; padding-bottom: 24px; color: var(--faint); font-size: 12.5px; border-top: 1px solid var(--border); margin-top: 24px; text-align: center; }
.brand-link { color: inherit; text-decoration: none; }
.muted-link { font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.muted-link:hover { color: var(--text); }
.licenses { display: block; max-width: 720px; padding-top: 40px; padding-bottom: 24px; line-height: 1.55; }
.licenses h1 { font-size: 26px; margin: 0 0 12px; }
.licenses h2 { font-size: 17px; margin: 24px 0 6px; }
.licenses a { color: var(--accent); }

/* Review on wide screens: the page is exactly the viewport; the viewer and the side panel each scroll on their own. */
@media (min-width: 1001px) {
  body:has(#review:not([hidden])) { height: 100vh; height: 100dvh; overflow: hidden; }
  body:has(#review:not([hidden])) > main { flex: 1 1 0; min-height: 0; align-items: stretch; padding-bottom: 16px; }
  body:has(#review:not([hidden])) .viewer { min-height: 0; }
  body:has(#review:not([hidden])) .pages { flex: 1 1 0; min-height: 0; overflow: auto; justify-content: flex-start; }
  body:has(#review:not([hidden])) .panel { position: static; max-height: none; min-height: 0; overflow: auto; }
  body:has(#review:not([hidden])) > footer { margin-top: 0; padding-top: 10px; padding-bottom: 12px; }
}

/* Responsive */
@media (max-width: 1000px) {
  main { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; order: -1; }
}
@media (max-width: 640px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .hero { padding-top: 32px; padding-bottom: 20px; }
  .drop { padding: 40px 18px 32px; }
  .topbar-inner { height: 64px; }
  .brand { font-size: 18px; }
  .drop-title { flex-direction: column; gap: 8px; }
  .pages { padding: 12px; }
  body:has(#review:not([hidden])) .names label { flex-direction: column; align-items: stretch; white-space: normal; }
  body:has(#review:not([hidden])) .names { margin: 0; flex-basis: 100%; }
  body:has(#review:not([hidden])) .drop-icon { display: none; }
  body:has(#review:not([hidden])) .drop-title { flex-direction: row; }
}
