:root {
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  color: var(--ink);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 64px; }
header h1 { font-size: 22px; margin: 12px 0 2px; }
header p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
input[type="text"] {
  flex: 1 1 220px;
  font-size: 20px;
  letter-spacing: 1px;
  padding: 14px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  min-width: 0;
}
input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

button {
  font-size: 16px;
  font-weight: 600;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.actions button { flex: 1 1 160px; }

.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.error { color: var(--danger); font-weight: 600; }
.banner {
  font-size: 13px; border-radius: 10px; padding: 10px 12px; margin-top: 12px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
}

.codes { display: grid; grid-template-columns: 1fr; gap: 16px; }
.code {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; text-align: center;
}
.code h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.code .val { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; margin-top: 10px; word-break: break-all; }
.code canvas { max-width: 100%; height: auto; }
.code .note { font-size: 12px; color: var(--muted); margin-top: 4px; }

#scanner {
  position: fixed; inset: 0; background: rgba(15,23,42,0.92);
  display: none; align-items: center; justify-content: center; flex-direction: column;
  z-index: 50; padding: 16px;
}
#scanner.open { display: flex; }
#scanner video {
  width: 100%; max-width: 520px; border-radius: 14px; background: #000;
  aspect-ratio: 3 / 4; object-fit: cover;
}
#scanner .scanbar { color: #fff; margin: 12px 0; font-size: 14px; min-height: 18px; text-align: center; }
#scanner .scan-actions { display: flex; gap: 10px; }
