:root {
  color-scheme: light;
  --forest: #174d36;
  --forest-hover: #103d2b;
  --forest-soft: #dce9df;
  --canvas: #f4f6f4;
  --surface: #fff;
  --surface-subtle: #edf1ed;
  --ink: #17211c;
  --muted: #526158;
  --line: #cbd3cc;
  --focus: #b85d00;
  --warning: #8a4b08;
  --danger: #a32d2d;
  --sticky: 20;
  --toast: 40;
  font-family: "Noto Sans", "Liberation Sans", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); color: var(--ink); }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, .button {
  min-height: 42px;
  border: 1px solid var(--forest);
  border-radius: 4px;
  background: var(--forest);
  color: #fff;
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 700;
  padding: 9px 14px;
  transition: background-color 150ms cubic-bezier(.22, 1, .36, 1), color 150ms cubic-bezier(.22, 1, .36, 1);
}
button:hover { background: var(--forest-hover); }
button:disabled { cursor: not-allowed; opacity: .55; }
.button-secondary { background: var(--surface); color: var(--forest); }
.button-secondary:hover { background: var(--surface-subtle); }
.button-compact { min-height: 34px; padding: 6px 10px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 1.25rem; letter-spacing: -.015em; line-height: 1.25; margin-bottom: 4px; }
h2 { font-size: 1rem; line-height: 1.3; }
p { color: var(--muted); font-size: .875rem; line-height: 1.5; }
label { color: var(--muted); display: grid; font-size: .8125rem; font-weight: 650; gap: 4px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
}
textarea { line-height: 1.45; min-height: 88px; resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-size: .875rem; font-weight: 700; margin-bottom: 8px; }
summary { color: var(--forest); cursor: pointer; font-size: .8125rem; font-weight: 700; }

.login-shell { align-items: center; display: flex; min-height: 100vh; padding: 24px; }
.login-form { margin: 0 auto; max-width: 360px; width: 100%; }
.login-form h1 { font-size: 1.5rem; }
.login-form label { margin: 16px 0; }
.login-form button { width: 100%; }
.form-error, .validation-message { color: var(--danger); min-height: 1.3em; }

.app-bar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  min-height: 52px;
  padding: 0 max(20px, calc((100vw - 1440px) / 2));
}
.app-bar > strong { margin-right: 10px; white-space: nowrap; }
.app-bar nav { align-self: stretch; display: flex; gap: 18px; }
.nav-link {
  align-self: stretch;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  min-height: auto;
  padding: 0 2px;
}
.nav-link:hover { background: transparent; color: var(--ink); }
.nav-link[aria-current="page"] { border-color: var(--forest); color: var(--ink); }
#account-name { color: var(--muted); font-size: .8125rem; margin-left: auto; }

main { margin: 0 auto; max-width: 1440px; padding: 24px 20px 40px; }
.page-head { align-items: flex-end; display: flex; gap: 24px; justify-content: space-between; margin-bottom: 20px; }
.page-head p { margin-bottom: 0; }

.queue-progress { border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); padding: 14px 0; }
.progress-track { background: var(--surface-subtle); height: 6px; overflow: hidden; }
.progress-track span { background: var(--forest); display: block; height: 100%; width: 0; }
.queue-progress dl { display: flex; flex-wrap: wrap; gap: 18px; margin: 10px 0 0; }
.queue-progress dl div { display: flex; gap: 5px; }
.queue-progress dt { color: var(--muted); font-size: .8125rem; }
.queue-progress dd { font-size: .8125rem; font-weight: 700; margin: 0; }
.resume-row { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 18px 0; }
.resume-row div { display: grid; gap: 3px; }
.resume-row span { color: var(--muted); font-size: .8125rem; }
.empty-state { border: 1px dashed var(--line); margin-top: 24px; padding: 28px; text-align: center; }

.workspace { max-width: none; }
.workspace-head {
  align-items: center;
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: auto 1fr auto;
  padding: 0 0 12px;
  position: sticky;
  top: 0;
  z-index: var(--sticky);
}
.record-context, .operational-state { display: grid; gap: 2px; }
.record-context span, .operational-state span { color: var(--muted); font-size: .75rem; }
.operational-state { min-width: 180px; text-align: right; }
.operational-state strong { color: var(--forest); font-size: .8125rem; }
.operational-state.warning strong { color: var(--warning); }
.operational-state.error strong { color: var(--danger); }
.workspace-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 350px; padding-top: 16px; }
.evidence-column { min-width: 0; }
.review-column { min-width: 0; }
.review-column > form, .reveal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 16px;
  padding: 16px;
  position: sticky;
  top: 68px;
}
.evidence-toolbar {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 50px;
  padding: 6px;
}
.evidence-toolbar label { min-width: 110px; }
.evidence-toolbar select { min-height: 34px; padding: 4px 7px; }
.segmented { display: flex; }
.segmented button {
  background: var(--surface);
  border-color: var(--line);
  border-radius: 0;
  color: var(--muted);
  margin-left: -1px;
  min-height: 36px;
  padding: 6px 9px;
}
.segmented button:first-child { border-radius: 4px 0 0 4px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 4px 4px 0; }
.segmented button[aria-pressed="true"] { background: var(--forest-soft); border-color: var(--forest); color: var(--forest); position: relative; }
.zoom-control { margin-left: auto; min-width: 130px; }
.zoom-control input { min-height: 34px; padding: 0; }

.comparison { background: #101411; border: 1px solid #101411; display: grid; grid-template-columns: 1fr 1fr; min-height: min(65vh, 720px); position: relative; }
.evidence-frame { color: #fff; display: grid; grid-template-rows: 1fr auto; margin: 0; min-width: 0; overflow: hidden; }
.evidence-frame + .evidence-frame { border-left: 1px solid #3e4741; }
.image-stage { cursor: grab; min-height: 0; overflow: hidden; position: relative; touch-action: none; }
.image-stage:active { cursor: grabbing; }
.image-stage img { height: 100%; object-fit: contain; transform-origin: center; user-select: none; width: 100%; }
.evidence-frame figcaption { background: #101411; border-top: 1px solid #3e4741; color: #f5f7f5; font-size: .75rem; min-height: 38px; padding: 9px 10px; }
.comparison-flicker, .comparison-swipe { display: block; }
.comparison-flicker .evidence-frame, .comparison-swipe .evidence-frame { inset: 0; position: absolute; }
.comparison-flicker .evidence-frame + .evidence-frame, .comparison-swipe .evidence-frame + .evidence-frame { border-left: 0; }
.comparison-flicker .evidence-frame { opacity: 0; }
.comparison-flicker .evidence-frame.is-visible { opacity: 1; }
.comparison-swipe #observation-frame { clip-path: inset(0 50% 0 0); }
.comparison-filmstrip { grid-template-columns: 1fr 1fr; }
.swipe-control { bottom: 46px; left: 50%; max-width: 300px; position: absolute; transform: translateX(-50%); width: calc(100% - 40px); z-index: 3; }
.swipe-control label { background: rgba(16,20,17,.9); color: #fff; padding: 8px; }
.swipe-control input { min-height: 28px; padding: 0; }
.frame-strip { border: 1px solid var(--line); border-top: 0; display: flex; gap: 1px; overflow-x: auto; }
.frame-strip button { background: var(--surface); border: 0; border-right: 1px solid var(--line); border-radius: 0; color: var(--muted); min-width: 145px; padding: 8px 10px; text-align: left; }
.frame-strip button[aria-pressed="true"] { box-shadow: inset 0 -3px var(--forest); color: var(--ink); }
.frame-strip small { display: block; margin-top: 2px; }

.location-context { border-bottom: 1px solid var(--line); margin-top: 12px; padding: 8px 0 12px; }
.location-grid { display: grid; gap: 16px; grid-template-columns: 300px 1fr; margin-top: 12px; }
#location-plot { background: var(--surface-subtle); border: 1px solid var(--line); height: 160px; width: 300px; }
#location-plot path { fill: none; stroke: var(--line); stroke-width: 1; }
#location-plot circle { fill: var(--forest); stroke: #fff; stroke-width: 2; }
dl { margin: 0; }
#quality-list, #reveal-metadata { display: grid; grid-template-columns: minmax(120px, .4fr) 1fr; }
#quality-list dt, #reveal-metadata dt { border-bottom: 1px solid var(--line); color: var(--muted); font-size: .75rem; padding: 5px 8px 5px 0; }
#quality-list dd, #reveal-metadata dd { border-bottom: 1px solid var(--line); font-size: .75rem; margin: 0; overflow-wrap: anywhere; padding: 5px 0; }

#review-form > label, .transition-fields, .field-pair { margin: 0; }
.transition-fields { display: grid; gap: 10px; }
.field-pair { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.radio-list { display: grid; gap: 1px; }
.radio-list label {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 22px 1fr;
  min-height: 42px;
  padding: 7px 9px;
}
.radio-list label:has(input:checked) { background: var(--forest-soft); border-color: var(--forest); }
.radio-list input { min-height: auto; width: auto; }
.form-actions { display: grid; gap: 10px; }
.skip-control { border-top: 1px solid var(--line); padding-top: 10px; }
.skip-control[open] { display: grid; gap: 10px; }
.skip-control summary { margin-bottom: 8px; }
.reveal-panel { position: sticky; }
.reveal-panel p { margin-bottom: 0; }
#mask-preview { background: #101411; max-height: 260px; object-fit: contain; width: 100%; }

.table-wrap { border: 1px solid var(--line); overflow-x: auto; }
table { border-collapse: collapse; min-width: 720px; width: 100%; }
th { background: var(--surface-subtle); color: var(--muted); font-size: .75rem; padding: 9px 10px; text-align: left; }
td { background: var(--surface); border-top: 1px solid var(--line); font-size: .8125rem; padding: 10px; vertical-align: top; }
.admin-summary { border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 16px; padding: 12px 0; }
.admin-summary span { color: var(--muted); font-size: .8125rem; }
.admin-summary strong { color: var(--ink); }
.toast { background: var(--ink); bottom: 20px; color: #fff; font-size: .8125rem; left: 50%; max-width: calc(100vw - 40px); padding: 10px 14px; position: fixed; transform: translateX(-50%); z-index: var(--toast); }

@media (max-width: 960px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .comparison { min-height: 520px; }
  .zoom-control { margin-left: 0; }
}

@media (max-width: 760px) {
  .app-bar { gap: 10px; overflow-x: auto; padding: 0 12px; }
  .app-bar > strong { display: none; }
  .app-bar nav { gap: 10px; }
  #account-name { display: none; }
  main { padding: 16px 12px 88px; }
  .page-head { align-items: stretch; flex-direction: column; gap: 12px; }
  .page-head button { width: 100%; }
  .workspace-head { grid-template-columns: auto 1fr; }
  .operational-state { grid-column: 1 / -1; min-height: 34px; text-align: left; }
  .workspace-grid { display: block; }
  .review-column { margin-top: 12px; }
  .review-column > form, .reveal-panel { border-radius: 0; bottom: 0; position: relative; top: auto; }
  .evidence-toolbar { align-items: stretch; }
  .segmented { order: 1; overflow-x: auto; width: 100%; }
  .segmented button { flex: 1 0 auto; }
  .evidence-toolbar label { flex: 1 1 42%; order: 2; }
  .evidence-toolbar > button { order: 2; }
  .comparison { display: block; min-height: 58vh; }
  .comparison .evidence-frame { inset: 0; position: absolute; }
  .comparison .evidence-frame + .evidence-frame { border-left: 0; }
  .comparison-side #reference-frame { display: none; }
  .comparison-side #observation-frame { display: grid; }
  .frame-strip button { min-height: 48px; min-width: 130px; }
  .location-grid { grid-template-columns: 1fr; }
  #location-plot { width: 100%; }
  .field-pair { grid-template-columns: 1fr; }
  .form-actions > button, #finalize-review { min-height: 48px; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
