/* Created with AI assistance */
:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1b1f24; --muted: #5b6470; --line: #d5d9df;
  --accent: #1f5fbf; --red: #d22f2f; --yellow: #e0a800; --green: #1f9d55;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171b; --card: #1e2329; --text: #e8eaed; --muted: #9aa3ad; --line: #363d46; --accent: #6ea8ff; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }
[hidden] { display: none !important; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.spacer { flex: 1; }
main { max-width: 720px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 12px; }
h1 { font-size: 1.2rem; margin: 0; }
label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
input, select, button { font: inherit; }
input:not([type=checkbox]):not([type=file]), select {
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%;
}
button { padding: 12px 18px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
button.quiet { background: transparent; color: var(--accent); border: 1px solid var(--line); padding: 6px 12px; font-weight: 500; }
button:disabled { opacity: 0.5; cursor: default; }
.error { color: var(--red); margin: 0; }
.hint { color: var(--muted); margin: 8px 0; min-height: 1.4em; }
.note { color: var(--muted); font-size: 0.9rem; margin: 0; padding-left: 18px; }
p.note { padding-left: 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.85rem; margin: 0; width: fit-content; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 12px 0; }

/* camera picture with the scan frame on top: the stage has the shape of the label plus a small margin,
   the video fills it ("cover") and is scaled for digital zoom */
#stage { position: relative; width: 100%; margin: 0 auto; background: #000; border-radius: 10px; overflow: hidden; line-height: 0; aspect-ratio: 3 / 1; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: 50% 50%; }
#frame { position: absolute; border: 3px solid var(--red); border-radius: 4px; box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.3); box-sizing: border-box; }
#frame.yellow { border-color: var(--yellow); }
#frame.green { border-color: var(--green); }
#elements, #code-marks { position: absolute; inset: 0; }
#elements div { position: absolute; border: 1px dashed #4dd0ff; color: #4dd0ff; font: 600 11px/1 system-ui, sans-serif; padding: 1px 2px; text-shadow: 0 0 2px #000; }
#code-marks div { position: absolute; border: 2px solid var(--green); background: rgba(31, 157, 85, 0.18); border-radius: 3px; }
#code-marks span { position: absolute; left: 0; bottom: 100%; margin-bottom: 2px; padding: 2px 5px; border-radius: 4px; background: var(--green); color: #fff; font: 600 12px/1.2 ui-monospace, monospace; white-space: nowrap; }
#code-banner { position: absolute; left: 8px; top: 8px; margin: 0; padding: 4px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.65); color: #fff; font: 600 13px/1.3 ui-monospace, monospace; }
#code-banner.ok { background: var(--green); }
.camera-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.camera-tools .zoom { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; }
.camera-tools .zoom input { flex: 1; }
.camera-tools select { width: auto; max-width: 100%; padding: 6px 10px; }
button.quiet[aria-pressed="true"] { background: var(--yellow); color: #000; border-color: var(--yellow); }

/* imported photo with the frame drawn by the user */
#mark-area { position: relative; touch-action: none; user-select: none; line-height: 0; cursor: crosshair; }
#mark-canvas { width: 100%; border-radius: 6px; background: #000; }
#mark-rect { position: absolute; border: 3px dashed var(--accent); background: rgba(31, 95, 191, 0.15); box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.35); pointer-events: none; }
#mark-area { overflow: hidden; border-radius: 6px; }

/* live values while aiming */
.live { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.live div { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 0.85rem; overflow: hidden; }
.live div.ok { border-color: var(--green); }
.live small { display: block; color: var(--muted); }

/* result */
#result-image { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#fields { display: grid; gap: 8px; }
#fields .row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
#fields .state { font-size: 0.8rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); margin-bottom: 10px; white-space: nowrap; }
#fields .state.confirmed { border-color: var(--green); color: var(--green); }
#fields .state.conflict, #fields .state.invalid, #fields .state.missing, #fields .state.unreadable { border-color: var(--red); color: var(--red); }
#fields .state.plausible, #fields .state.reconstructed { border-color: var(--yellow); color: var(--yellow); }
pre { overflow: auto; max-height: 50vh; font-size: 0.75rem; background: var(--bg); padding: 8px; border-radius: 6px; margin: 0; }
