:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --text: #1b1b1b;
  --muted: #666;
  --border: #ddd;
  --red: #d01012;
  --red-text: #ffffff;
  --green: #1e7d32;
  --amber: #b26a00;
  --grey: #777;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #f0f0f0;
    --muted: #aaa;
    --border: #333;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
h1 { font-size: 26px; margin: 8px 0 4px; letter-spacing: .5px; }
h2 { font-size: 20px; margin: 4px 0; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 15px; }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 56px;
  width: 100%;
  text-align: center;
  cursor: pointer;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .45; }
.primary { background: var(--red); color: var(--red-text); border-color: var(--red); font-weight: 700; }
.hero { min-height: 150px; font-size: 26px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid button { min-height: 72px; font-size: 20px; font-weight: 600; }
.link { background: none; border: none; color: var(--muted); min-height: 44px; padding: 8px; text-decoration: underline; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
}
.card img { width: 88px; height: 88px; object-fit: contain; background: #fff; border-radius: 8px; flex-shrink: 0; }
.card .info { flex: 1; min-width: 0; }
.card .num { font-size: 22px; font-weight: 800; }
.card .name { font-weight: 600; }
button.card { min-height: 0; }
.card.top { border: 2px solid var(--red); flex-direction: column; align-items: stretch; }
.card.top .pics { display: flex; gap: 8px; }
.card.top .pics img { flex: 1; width: 50%; height: 160px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; }
.badge.Identificato { background: var(--green); }
.badge.Probabile { background: var(--amber); }
.badge.Sconosciuto { background: var(--grey); }

.thumbs { display: flex; gap: 8px; overflow-x: auto; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }

input[type=text], input[type=url], input[type=password], input[inputmode] {
  font: inherit;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }

.spinner {
  width: 44px; height: 44px; margin: 24px auto;
  border: 4px solid var(--border); border-top-color: var(--red);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.done { text-align: center; padding: 20px 0; }
.done .id { font-size: 40px; font-weight: 900; color: var(--green); letter-spacing: 1px; }
.crumb { font-size: 15px; color: var(--muted); }
.notice {
  background: #fff4e0; color: #5c3b00; border: 1px solid #f0c36d;
  border-radius: var(--radius); padding: 12px 14px; font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  .notice { background: #3a2a0a; color: #ffdc9a; border-color: #7a5a1a; }
}
.stat { font-size: 15px; color: var(--muted); text-align: center; }

#toast {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  background: #b00020; color: #fff; padding: 14px 16px;
  border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.25);
  max-width: 528px; margin: 0 auto;
}
