:root {
  color-scheme: light;
  --ink: #071637;
  --muted: #59657a;
  --line: #d7deea;
  --line-strong: #bdc8d8;
  --well: #f2f6fa;
  --teal: #087f88;
  --teal-dark: #05666e;
  --green: #0b8a46;
  --amber: #bd5900;
  --amber-bg: #fff8f0;
  --blue-bg: #f2f7ff;
  --danger: #a92d27;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }

button, input, select { -webkit-tap-highlight-color: transparent; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.header-inner {
  display: flex;
  align-items: baseline;
  gap: 36px;
  width: min(1480px, calc(100% - 64px));
  margin: 0 auto;
  padding: 11px 0;
}

.brand {
  color: var(--ink);
  font-size: 29px;
  font-weight: 760;
  letter-spacing: -.035em;
  text-decoration: none;
}

.environment { font-size: 17px; font-weight: 520; }

.page-shell {
  width: min(1480px, calc(100% - 64px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(340px, 1fr);
  gap: 42px;
  align-items: start;
}

.intro { margin: 0 0 20px; }

.intro h1 {
  margin: 0;
  font-size: clamp(34px, 3vw, 44px);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.intro p { margin: 10px 0 0; color: #26344e; font-size: 17px; }

.tuning-consent {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid #f0c79d;
  border-radius: 7px;
  background: var(--amber-bg);
  color: #3d2a12;
  font-size: 14px;
}

.tuning-consent input { margin-top: 3px; }

.tuning-consent {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid #f0c79d;
  border-radius: 7px;
  background: var(--amber-bg);
  color: #3d2a12;
  font-size: 14px;
}

.tuning-consent input { margin-top: 3px; }

.field { max-width: 720px; margin-bottom: 18px; }

.field label, .panel-heading h2, .comparison h2, .comparison h3 {
  font-weight: 680;
}

.field label { display: block; margin-bottom: 6px; font-size: 14px; }

.field input {
  width: 100%;
  height: 42px;
  padding: 8px 12px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  outline: none;
}

.field input:focus-visible { border-color: var(--teal); box-shadow: 0 0 0 3px rgb(8 127 136 / 14%); }

.field-help { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.upload-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
}

.panel-heading h2 { margin: 0; font-size: 15px; }

.upload-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.upload-state.selected { color: var(--green); }

.photo-well {
  position: relative;
  display: grid;
  height: 228px;
  min-height: 228px;
  margin: 0 12px;
  overflow: hidden;
  place-items: center;
  border: 1px dashed #c6d1df;
  border-radius: 6px;
  background: var(--well);
}

.photo-well img { width: 100%; height: 100%; max-height: 340px; object-fit: contain; background: #eef3f8; }
.selfie-well img { object-fit: cover; }

.photo-placeholder { display: grid; max-width: 230px; justify-items: center; gap: 12px; padding: 28px; color: var(--muted); text-align: center; }
.photo-placeholder svg { width: 58px; fill: none; stroke: #7d8ba1; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.photo-placeholder span { font-size: 14px; }

.upload-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 12px;
}

.capture-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.capture-button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-dark); }
.capture-button:focus-visible { outline: 3px solid rgb(8 127 136 / 16%); outline-offset: 2px; }
.capture-button:disabled { cursor: not-allowed; opacity: .5; }
.capture-button svg { width: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.capture-summary { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.form-actions { display: flex; align-items: center; gap: 18px; margin: 14px 0 10px; }
.form-actions p { max-width: 560px; margin: 0; color: var(--muted); font-size: 12px; }

.primary-button {
  min-height: 42px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.primary-button {
  min-width: 130px;
  padding: 9px 22px;
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.primary-button:hover:not(:disabled) { border-color: var(--teal-dark); background: var(--teal-dark); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
.primary-button:focus-visible { outline: 3px solid rgb(8 127 136 / 20%); outline-offset: 2px; }

.form-error { margin: 8px 0 14px; padding: 10px 12px; border-left: 3px solid var(--danger); background: #fff5f4; color: #79231f; font-size: 14px; }

.comparison { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--line-strong); }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.comparison-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.comparison-item + .comparison-item { padding-left: 16px; border-left: 1px solid var(--line); }
.comparison-item h3 { margin: 0 0 10px; font-size: 14px; }

.comparison-image {
  display: grid;
  height: 225px;
  overflow: hidden;
  place-items: center;
  border-radius: 7px;
  background: var(--well);
  color: var(--muted);
  font-size: 13px;
}

.comparison-image img { width: 100%; height: 100%; object-fit: contain; }
.selfie-comparison img { object-fit: cover; }

.image-facts { margin: 10px 0 0; }
.image-facts div { display: grid; grid-template-columns: 94px minmax(0, 1fr); gap: 10px; padding: 4px 0; }
.image-facts dt { font-size: 12px; font-weight: 680; }
.image-facts dd { min-width: 0; margin: 0; overflow: hidden; color: #293750; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.results-panel { position: sticky; top: 18px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
.results-panel > h2 { margin: 0; padding: 21px 24px 16px; border-bottom: 1px solid var(--line); font-size: 20px; }
.result-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; min-height: 86px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.result-row strong, .result-row span { display: block; }
.result-row strong { font-size: 15px; }
.result-row div > span { margin-top: 2px; color: var(--muted); font-size: 13px; }

.result-icon { width: 36px; height: 36px; border: 2px solid #aab5c4; border-radius: 50%; }
.result-row.success .result-icon { position: relative; border-color: var(--green); }
.result-row.success .result-icon::after { position: absolute; top: 8px; left: 9px; width: 12px; height: 7px; border-bottom: 2px solid var(--green); border-left: 2px solid var(--green); content: ""; transform: rotate(-45deg); }
.result-row.error .result-icon { border-color: var(--danger); }
.result-row.warn .result-icon { border-color: var(--amber); }

.manual-review { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; margin: 16px 14px; padding: 16px; border: 1px solid #f0c79d; border-radius: 7px; background: var(--amber-bg); }
.manual-review svg { width: 34px; fill: none; stroke: var(--amber); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.manual-review strong { display: block; font-size: 15px; }
.manual-review p { margin: 4px 0 0; color: #493a2d; font-size: 13px; }

.run-details { margin: 0 20px; padding: 14px 4px; border-top: 1px solid var(--line); }
.run-details div { display: grid; grid-template-columns: 125px minmax(0, 1fr); gap: 10px; padding: 4px 0; }
.run-details dt { font-size: 12px; font-weight: 680; }
.run-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #33405a; font-size: 12px; }

.retained-actions { margin: 0 20px 16px; padding: 14px 4px 0; border-top: 1px solid var(--line); }
.retained-actions p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.delete-button {
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--danger);
  border-radius: 5px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  font-weight: 700;
}
.delete-button:hover:not(:disabled) { background: #fff5f4; }
.delete-button:disabled { cursor: not-allowed; opacity: .55; }
.delete-button:focus-visible { outline: 3px solid rgb(169 45 39 / 16%); outline-offset: 2px; }

.boundary-note { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; margin: 0 14px 14px; padding: 14px; border: 1px solid #c7d7ec; border-radius: 7px; background: var(--blue-bg); }
.boundary-note svg { width: 31px; fill: none; stroke: #1465ba; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.boundary-note p { margin: 0; color: #243858; font-size: 12px; }

.camera-dialog {
  width: min(760px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 22px 70px rgb(7 22 55 / 28%);
}

.camera-dialog::backdrop { background: rgb(7 22 55 / 65%); }

.camera-shell { padding: 20px; }

.camera-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.camera-kicker { display: block; color: var(--teal-dark); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.camera-heading h2 { margin: 2px 0 0; font-size: 23px; line-height: 1.2; }
.camera-instructions { margin: 9px 46px 15px 0; color: #33405a; font-size: 14px; }

.camera-close-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.camera-close-button:hover { border-color: var(--teal); color: var(--teal-dark); }
.camera-close-button:focus-visible, .camera-cancel-button:focus-visible, .camera-device-field select:focus-visible { outline: 3px solid rgb(8 127 136 / 18%); outline-offset: 2px; }

.camera-device-field { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; margin-bottom: 12px; }
.camera-device-field label { font-size: 13px; font-weight: 680; }
.camera-device-field select { min-width: 0; height: 38px; padding: 6px 30px 6px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; color: var(--ink); }

.camera-preview {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: var(--camera-aspect, 16 / 9);
  max-height: min(64vh, 580px);
  overflow: hidden;
  place-items: center;
  border-radius: 7px;
  background: #07101f;
}

.camera-preview video { width: 100%; height: 100%; object-fit: contain; }
.camera-status { position: absolute; margin: 0; padding: 8px 11px; border-radius: 5px; background: rgb(7 22 55 / 82%); color: #fff; font-size: 14px; }
.camera-error { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--danger); background: #fff5f4; color: #79231f; font-size: 14px; }

.camera-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.camera-actions .primary-button { min-width: 118px; }
.camera-cancel-button { min-height: 42px; padding: 9px 18px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 650; }
.camera-cancel-button:hover { border-color: var(--teal); color: var(--teal-dark); }

[hidden] { display: none !important; }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .results-panel { position: static; }
}

@media (max-width: 680px) {
  .site-header { background: var(--ink); color: #fff; }
  .header-inner { display: block; width: calc(100% - 40px); padding: 16px 0; }
  .brand { display: block; color: #fff; font-size: 26px; }
  .environment { display: block; margin-top: 1px; color: #fff; font-size: 15px; }
  .page-shell { width: calc(100% - 40px); padding-top: 30px; }
  .intro h1 { font-size: 34px; }
  .intro p { font-size: 16px; }
  .upload-grid, .comparison-grid { grid-template-columns: minmax(0, 1fr); }
  .photo-well { min-height: 240px; }
  .comparison-item + .comparison-item { padding-top: 18px; padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .form-actions { display: block; }
  .primary-button { width: 100%; }
  .form-actions p { margin-top: 9px; }
  .results-panel > h2 { padding-right: 18px; padding-left: 18px; }
  .result-row { padding-right: 18px; padding-left: 18px; }
  .section-heading { display: block; }
  .section-heading span { display: block; margin-top: 2px; }
  .camera-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
  .camera-shell { padding: 16px; }
  .camera-instructions { margin-right: 0; }
  .camera-device-field { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .camera-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .camera-actions button { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-button, .capture-button, .camera-close-button, .camera-cancel-button, .field input { transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease; }
}
