:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #15171c; --muted: #646a75; --line: #dde0e6;
  --accent: #1f6feb; --ok: #12805c; --ok-bg: #e3f5ec; --bad: #c62828; --bad-bg: #fde8e8;
  --warn: #9a6200; --warn-bg: #fff3d6; --pending: #6b7280;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #181b21; --text: #eceef2; --muted: #9aa1ad; --line: #2a2f38;
    --accent: #5b9dff; --ok: #3ccf91; --ok-bg: #0f2f22; --bad: #ff6b6b; --bad-bg: #3a1414;
    --warn: #ffc24d; --warn-bg: #3a2c0c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #181b21; --text: #eceef2; --muted: #9aa1ad; --line: #2a2f38;
  --accent: #5b9dff; --ok: #3ccf91; --ok-bg: #0f2f22; --bad: #ff6b6b; --bad-bg: #3a1414;
  --warn: #ffc24d; --warn-bg: #3a2c0c; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 96px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(8px); padding-top: max(12px, env(safe-area-inset-top)); max-width: 760px; margin: 0 auto; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand span { font-weight: 600; color: var(--muted); margin-left: 4px; }
.engine { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.engine.ready { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.engine.ready.slow { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.engine.error { color: var(--bad); }

.tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; padding: 6px 16px; max-width: 760px; margin: 0 auto;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.tabs button { flex: 1; min-height: 44px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tabs b { font-weight: 700; opacity: .75; margin-left: 2px; }

.tab { display: none; padding-top: 10px; }
.tab.active { display: block; }

button.primary, .primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; min-height: 44px; font-weight: 700; cursor: pointer; }
button.ghost, .ghost { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-height: 40px; cursor: pointer; }
.ghost.danger { color: var(--bad); }
.small { min-height: 32px !important; padding: 4px 10px !important; font-size: 13px; }
.big { font-size: 17px; padding: 14px 22px; }
.hint { color: var(--muted); font-size: 13px; }

.viewport { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
@media (max-width: 600px) { .viewport { aspect-ratio: 3 / 4; } }
.viewport video, .viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewport-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #d6d9df; padding: 16px; }
.viewport-empty .hint { color: #a3a9b4; }
.hud { position: absolute; left: 8px; right: 8px; top: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #fff; }
.hud span { background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 6px; }
.hud .ghost { background: rgba(0,0,0,.55); color: #fff; border-color: rgba(255,255,255,.3); }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 2px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; min-height: 32px; }
.switch input { width: 18px; height: 18px; }

.cards { display: grid; gap: 8px; }
.card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 14px;
  border-radius: var(--radius); background: var(--panel); border: 2px solid var(--line); }
.card .plate { font-size: 26px; font-weight: 800; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.card .memo { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.card .actions { display: flex; gap: 6px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.st-registered { border-color: var(--ok); } .st-registered .badge { background: var(--ok-bg); color: var(--ok); }
.st-unregistered { border-color: var(--bad); background: var(--bad-bg); } .st-unregistered .badge { background: var(--bad); color: #fff; }
.st-similar { border-color: var(--warn); } .st-similar .badge { background: var(--warn-bg); color: var(--warn); }
.st-pending { border-style: dashed; } .st-pending .badge { color: var(--pending); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.section-head h2 { font-size: 15px; margin: 0; }
.history { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.history li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; background: var(--panel); border-radius: 10px; border-left: 4px solid var(--line); }
.history li.st-registered { border-left-color: var(--ok); }
.history li.st-unregistered { border-left-color: var(--bad); }
.history li.st-similar { border-left-color: var(--warn); }
.history time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.history .p { font-weight: 700; font-variant-numeric: tabular-nums; }
.history .s { font-size: 12px; font-weight: 700; }
.history .st-registered .s, .history li.st-registered .s { color: var(--ok); }
.history li.st-unregistered .s { color: var(--bad); }
.history li.st-similar .s { color: var(--warn); }

.file-pick { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-wrap { margin: 10px 0; }
.photo-wrap canvas { width: 100%; height: auto; border-radius: var(--radius); display: block; }

.row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.row input { flex: 1 1 140px; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); min-width: 0; }
#reg-paste textarea, #reg-search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
#reg-paste { margin-bottom: 10px; display: grid; gap: 8px; }
#reg-search { min-height: 44px; }
.reg-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.reg-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-radius: 10px; }
.reg-list .p { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 96px; }
.reg-list .m { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-list button { min-height: 32px; padding: 2px 10px; }

.toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  display: flex; gap: 12px; align-items: center; background: #23262d; color: #fff; padding: 10px 14px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: calc(100% - 32px); }
.toast button { background: transparent; border: 0; color: #8ab4ff; font-weight: 800; min-height: 36px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }

.site-foot { margin-top: 32px; text-align: center; font-size: 13px; }
.site-foot a { color: var(--muted); text-decoration: none; display: inline-block; padding: 10px 12px; }
.site-foot a:hover { color: var(--text); text-decoration: underline; }
.site-ver { display: block; color: var(--muted); font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
