:root {
  --bg: #fff; --fg: #0c0a09; --muted: #f5f5f4; --muted-fg: #78716c; --border: #e7e5e4;
  --primary: #1c1917; --on-primary: #fafaf9; --radius: 16px; --plate-ink: #0a0a0a; --plate-bg: #fafafa;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09; --fg: #fafaf9; --muted: #292524; --muted-fg: #a8a29e; --border: #292524;
    --primary: #fafaf9; --on-primary: #1c1917;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--fg);
  font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
#app { flex: 1; width: 100%; max-width: 480px; margin: 0 auto; padding: 16px 16px 24px; display: flex; flex-direction: column; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Loader */
.loader { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.logo { width: auto; height: 64px; }
/* The logo artwork is near-white: darken it on the light theme. */
.logo, .footer .branding img { filter: invert(1); }
@media (prefers-color-scheme: dark) { .logo, .footer .branding img { filter: none; } }
.brand { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.brand small { font-size: 14px; font-weight: 600; margin-left: 2px; }
.progress { width: 128px; height: 4px; margin-top: 16px; border-radius: 4px; background: var(--muted); overflow: hidden; }
.progress::after { content: ""; display: block; width: 40%; height: 100%; border-radius: 4px; background: var(--primary); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* Unavailable */
.unavailable { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 32px; }
.icon-large { width: 48px; height: 48px; color: var(--muted-fg); margin-bottom: 8px; }
.unavailable h1 { font-size: 20px; font-weight: 600; }
.unavailable p, .muted { color: var(--muted-fg); font-size: 13px; }
.unavailable .btn { margin-top: 16px; }

/* Hero */
.hero { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 0; }
.texture {
  position: absolute; inset: 0; border-radius: var(--radius); pointer-events: none;
  background:
    radial-gradient(circle, transparent 0, var(--bg) 100%),
    repeating-linear-gradient(45deg, transparent 0 11px, color-mix(in srgb, var(--fg) 7%, transparent) 11px 12px),
    repeating-linear-gradient(-45deg, transparent 0 11px, color-mix(in srgb, var(--fg) 7%, transparent) 11px 12px);
}
.avatar { position: relative; width: 96px; height: 96px; border-radius: 50%; background: var(--muted) center / cover; display: grid; place-items: center; font-size: 32px; font-weight: 600; color: var(--muted-fg); overflow: hidden; }
.hero h1 { position: relative; font-size: 18px; font-weight: 600; text-align: center; }

/* Plate */
.plate-card { margin-top: 16px; padding: 16px; border-radius: var(--radius); background: var(--muted); }
.plate {
  position: relative; display: flex; height: 80px; overflow: hidden; border-radius: 8px; background: var(--plate-bg);
  box-shadow: inset 0 0 0 2px var(--plate-ink); color: var(--plate-ink);
}
.plate::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%); background-size: 250% 100%; animation: sheen 5s ease-in-out infinite; }
@keyframes sheen { 0%, 60% { background-position: 150% 0; } 100% { background-position: -50% 0; } }
.plate .band { width: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10px; font-weight: 700; }
.plate .band svg { width: 18px; height: 18px; }
.plate .number { flex: 1; display: grid; place-items: center; padding: 0 12px; font: 700 clamp(18px, 7vw, 28px)/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px; white-space: nowrap; }
.plate .mark { position: absolute; left: 40px; right: 0; bottom: 2px; display: flex; justify-content: space-between; padding: 0 12px; font-size: 10px; opacity: .4; }

/* Details */
.details { margin: 24px 0 0; }
.details .row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.details .row:first-child { border-top: 0; }
.details dt { flex: 1; color: var(--muted-fg); font-size: 13px; }
.details dd { flex: 2; margin: 0; display: flex; justify-content: flex-end; align-items: center; gap: 8px; text-align: right; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--fg) 30%, transparent); }

/* Photos */
.photos { margin-top: 16px; }
.photos h2 { font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photo { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.photo .frame, .photo-skeleton { aspect-ratio: 1; width: 100%; border-radius: 8px; border: 1px solid var(--border); background: var(--muted); object-fit: cover; display: block; }
.photo span { font-size: 11px; color: var(--muted-fg); }
.photo-skeleton { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* Footer + buttons */
.footer { position: sticky; bottom: 0; width: 100%; max-width: 480px; margin: 0 auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 24px); }
.actions { display: flex; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 8px; font: 500 14px/1 inherit; cursor: pointer; text-decoration: none; color: var(--fg); background: none; }
.btn.primary { flex: 1; justify-content: space-between; background: var(--primary); color: var(--on-primary); }
.btn.secondary { background: var(--muted); }
.btn.outline { border-color: var(--border); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .tag-id:focus-visible, .photo:focus-visible, .reason:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
#app[data-state="loading"] ~ .footer .btn.secondary, #app[data-state="unavailable"] ~ .footer .btn.secondary { flex: 1; }
.tag-id { display: block; width: 100%; padding: 8px 0; border: 0; background: none; color: var(--muted-fg); font: 11px ui-monospace, Menlo, monospace; text-align: center; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.branding { display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--muted-fg); font-size: 12px; font-weight: 600; letter-spacing: 2px; text-decoration: none; padding-bottom: 8px; }

/* Sheets */
.sheet { width: min(480px, 100%); max-width: 100%; margin: auto auto 0; padding: 16px; border: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--bg); color: var(--fg); }
.sheet::backdrop { background: rgb(0 0 0 / .5); }
.sheet[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet form { display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { font-size: 18px; font-weight: 600; }
.reasons { display: flex; flex-direction: column; max-height: 50dvh; overflow: auto; margin: 4px 0; }
.reason { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: 13px/1.3 inherit; text-align: left; cursor: pointer; }
.reason:hover { background: var(--muted); }
.reason span { flex: 1; }
.reason .check { opacity: .4; }
.reason[aria-checked="true"] .check { opacity: 1; }
.photo-sheet img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; padding: 10px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); box-shadow: 0 8px 24px rgb(0 0 0 / .2); font-size: 13px; z-index: 10; }
.toast span { color: var(--muted-fg); }

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