:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5b616e;
  --border: #dde0e6;
  --accent: #1f4fd1;
  --accent-text: #ffffff;
  --plate-yellow: #f7b500;
  --plate-blue: #003399;
  --ok: #157a3c;
  --warn: #a35a00;
  --bad: #b3261e;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318;
    --surface: #1b1e25;
    --text: #eceef2;
    --muted: #a3a9b6;
    --border: #2d313b;
    --accent: #7aa2ff;
    --accent-text: #0c1020;
    --ok: #5fd28c;
    --warn: #f2b45a;
    --bad: #ff8a80;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111318;
  --surface: #1b1e25;
  --text: #eceef2;
  --muted: #a3a9b6;
  --border: #2d313b;
  --accent: #7aa2ff;
  --accent-text: #0c1020;
  --ok: #5fd28c;
  --warn: #f2b45a;
  --bad: #ff8a80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.75rem; margin: 0 0 4px; }
.lead { margin: 0 0 20px; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:focus-within, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .6; cursor: progress; }

.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.preview { margin: 16px 0 0; }
.preview canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  touch-action: none;
  cursor: crosshair;
  background: #000;
}
.preview figcaption { font-size: .875rem; color: var(--muted); margin-top: 6px; }

.plate-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
}
.plate-label { grid-column: 1 / -1; font-weight: 600; margin-bottom: -4px; }

.plate {
  display: flex;
  height: 56px;
  border: 2px solid #111;
  border-radius: 8px;
  overflow: hidden;
  background: var(--plate-yellow);
}
.plate-eu {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 30px;
  padding-bottom: 6px;
  background: var(--plate-blue);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
}
.plate-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #111;
  font: 700 1.6rem/1 "DIN Alternate", "Arial Narrow", system-ui, sans-serif;
  letter-spacing: .06em;
  text-align: center;
  text-transform: uppercase;
}
.plate-input::placeholder { color: rgba(0, 0, 0, .35); }
.plate-input:focus { outline: none; }
.plate:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.plate-form .btn { height: 56px; }

.candidates { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #111;
  background: var(--plate-yellow);
  color: #111;
  font: 700 1rem system-ui, sans-serif;
  letter-spacing: .05em;
  cursor: pointer;
}

.status { margin: 12px 0 0; min-height: 1.5em; color: var(--muted); }
.status.error { color: var(--bad); }
progress { width: 100%; height: 6px; margin-top: 6px; accent-color: var(--accent); }

.result h2 { margin: 0; font-size: 1.4rem; }
.result .sub { margin: 2px 0 14px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.badge {
  font-size: .85rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin: 0; }
.facts div { padding: 8px 0; border-top: 1px solid var(--border); min-width: 0; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 380px) { .facts { grid-template-columns: 1fr; } }

.foot { font-size: .85rem; color: var(--muted); }
.foot a { color: var(--accent); }
