:root {
  --bg: #f2f2f5;
  --card: #ffffff;
  --ink: #0b0b0f;
  --muted: #6e6e78;
  --line: #e3e3e8;
  --accent: #0a66ff;
  --ok: #1f9d55;
  --warn: #c77700;
  --bad: #d92d20;
  --radius: 22px;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px; }
header.top { display: flex; align-items: center; gap: 12px; padding: 14px 20px; position: sticky; top: 0; background: rgba(242, 242, 245, 0.82); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); z-index: 5; border-bottom: 1px solid var(--line); }
header.top .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
header.top .brand i { width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--ink); display: inline-block; box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 7px var(--ink); }
header.top nav { margin-left: auto; display: flex; gap: 4px; }
header.top nav a { padding: 7px 12px; border-radius: 999px; color: var(--ink); font-size: 14px; }
header.top nav a[aria-current='page'] { background: var(--ink); color: #fff; }
h1 { font-size: 34px; letter-spacing: -0.03em; margin: 8px 0 4px; }
h2 { font-size: 19px; letter-spacing: -0.01em; margin: 0 0 12px; }
p.lead { color: var(--muted); margin: 0 0 22px; font-size: 17px; }
.card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.05); }
.grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } h1 { font-size: 28px; } }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: #fafafc; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(10, 102, 255, .14); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 999px; border: 0; background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; transition: transform .08s, opacity .15s; flex: 0 0 auto; }
.btn:active { transform: scale(.97); }
.btn.secondary { background: #e9e9ee; color: var(--ink); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
.btn:disabled { opacity: .4; cursor: default; }
.seg { display: inline-flex; background: #e9e9ee; border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.preview { display: grid; place-items: center; background: linear-gradient(180deg, #fbfbfd, #eef0f3); border-radius: 18px; min-height: 340px; padding: 18px; }
.preview img { width: min(320px, 100%); height: auto; filter: drop-shadow(0 10px 30px rgba(0,0,0,.12)); }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e9e9ee; }
.pill.ok { background: #e5f6ec; color: var(--ok); }
.pill.bad { background: #fde8e7; color: var(--bad); }
.pill.warn { background: #fff2dd; color: var(--warn); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; word-break: break-all; }
.list { margin: 0; padding: 0; list-style: none; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.list li:last-child { border-bottom: 0; }

/* ---------- scanner ---------- */
body.scanner { background: #000; color: #fff; height: 100dvh; overflow: hidden; }
body.scanner header.top { background: rgba(0,0,0,.45); border-bottom: 0; color: #fff; position: fixed; left: 0; right: 0; }
body.scanner header.top .brand i { border-color: #fff; box-shadow: inset 0 0 0 3px #000, inset 0 0 0 7px #fff; }
body.scanner header.top nav a { color: #fff; }
body.scanner header.top nav a[aria-current='page'] { background: #fff; color: #000; }
.stage { position: fixed; inset: 0; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.guide { position: absolute; left: 50%; top: 46%; width: min(66vw, 46vh); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; box-shadow: 0 0 0 200vmax rgba(0,0,0,.35); pointer-events: none; }
.guide::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.03); opacity: .6; } }
.toolbar { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 12px; z-index: 4; }
.round { width: 54px; height: 54px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 20px; cursor: pointer; display: grid; place-items: center; }
.round[aria-pressed=true] { background: #fff; color: #000; }
.start { position: fixed; inset: 0; display: grid; place-items: center; z-index: 3; text-align: center; padding: 24px; }
.start p { color: rgba(255,255,255,.7); max-width: 340px; }
.result { position: fixed; left: 12px; right: 12px; bottom: calc(90px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 460px; border-radius: 26px; padding: 18px 20px; background: rgba(255,255,255,.96); color: var(--ink); z-index: 6; box-shadow: 0 20px 60px rgba(0,0,0,.4); transform: translateY(140%); transition: transform .32s cubic-bezier(.2,.9,.2,1.1); }
.result.show { transform: translateY(0); }
.result .head { display: flex; align-items: center; gap: 12px; }
.result .icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 24px; font-weight: 800; flex: 0 0 auto; }
.result.ok .icon { background: var(--ok); }
.result.warn .icon { background: var(--warn); }
.result.bad .icon { background: var(--bad); }
.result.info .icon { background: var(--accent); }
.result .title { font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
.result .sub { color: var(--muted); font-size: 13px; }
.result .body { margin-top: 12px; font-size: 16px; white-space: pre-wrap; word-break: break-word; }
.flash { position: fixed; inset: 0; pointer-events: none; z-index: 2; opacity: 0; transition: opacity .5s; }
.flash.ok { background: radial-gradient(circle, rgba(31,157,85,.0) 40%, rgba(31,157,85,.55)); opacity: 1; transition: none; }
.flash.bad { background: radial-gradient(circle, rgba(217,45,32,.0) 40%, rgba(217,45,32,.6)); opacity: 1; transition: none; }
.flash.warn { background: radial-gradient(circle, rgba(199,119,0,.0) 40%, rgba(199,119,0,.6)); opacity: 1; transition: none; }
.stats { position: fixed; top: 64px; right: 14px; font-size: 11px; color: rgba(255,255,255,.65); z-index: 4; font-variant-numeric: tabular-nums; }
dialog { border: 0; border-radius: 24px; padding: 24px; width: min(440px, 92vw); color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(4px); }
.hidden { display: none !important; }
.row.center { justify-content: center; } .row.center > * { flex: 0 0 auto; }
.row.end { justify-content: flex-end; margin-top: 16px; } .row.end > * { flex: 0 0 auto; }
label.btn.inline { margin: 0; color: var(--ink); }
header.top .brand img.logo { width: 26px; height: 26px; }
body.scanner header.top .brand img.logo { filter: invert(1); }
body.ticket { background: #fff; text-align: center; }
body.ticket .wrap { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
img.bigcode { width: min(92vw, 70vh); height: auto; }
