:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --border: #2c313c;
  --text: #e9ecf2;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --ok: #1fa463;
  --warn: #f0a020;
  --err: #e5484d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.sound-pill {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 700;
}
.sound-pill:active { background: var(--accent); border-color: var(--accent); color: #fff; }

.topbar .stat { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.topbar .stat small { color: var(--muted); font-weight: 400; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 24px); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

input, select, button {
  font: inherit;
  color: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  padding: 12px 14px;
  min-height: 46px;
}
input, select { width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button { cursor: pointer; font-weight: 600; white-space: nowrap; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { background: transparent; border-color: var(--err); color: var(--err); }
button.ghost { background: transparent; }
button.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }
button.block { width: 100%; }

.muted { color: var(--muted); }
.error { color: var(--err); white-space: pre-wrap; }
.success { color: var(--ok); white-space: pre-wrap; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
}
.badge.ok { background: rgba(31, 164, 99, .18); color: #4cd38d; }
.badge.warn { background: rgba(240, 160, 32, .18); color: var(--warn); }
.badge.err { background: rgba(229, 72, 77, .18); color: #ff7a7e; }

/* ---------- key/value table (extra columns) ---------- */
.kv { width: 100%; border-collapse: collapse; font-size: 15px; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.kv th { width: 34%; color: var(--muted); font-weight: 500; padding-right: 12px; word-break: break-all; }
.kv td { word-break: break-word; white-space: pre-wrap; }
.kv td.empty { color: var(--muted); }

/* ---------- scanner ---------- */
.reader-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 62vh;
  margin: 0 auto 14px;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
#reader { width: 100%; height: 100%; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
#reader-placeholder.hidden { display: none; }
#reader-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 20px; text-align: center;
}

/* ---------- result overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.overlay.show { display: flex; }
.overlay .banner {
  padding: calc(env(safe-area-inset-top) + 22px) 20px 22px;
  text-align: center;
}
.overlay .banner .icon { font-size: 56px; line-height: 1; }
.overlay .banner .title { font-size: 26px; font-weight: 800; margin-top: 8px; }
.overlay .banner .sub { margin-top: 6px; font-size: 15px; opacity: .92; }
.overlay.ok .banner { background: var(--ok); color: #fff; }
.overlay.duplicate .banner { background: var(--warn); color: #1b1300; }
.overlay.not_found .banner { background: var(--err); color: #fff; }
.overlay .body { padding: 18px 18px 0; flex: 1; }
.overlay .name { font-size: 30px; font-weight: 800; word-break: break-word; }
.overlay .hash { font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--muted); word-break: break-all; margin-top: 4px; }
.overlay .dup-info {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: rgba(240, 160, 32, .14); border: 1px solid rgba(240, 160, 32, .5);
  font-size: 15px; line-height: 1.5;
}
.overlay .footer {
  position: sticky; bottom: 0;
  padding: 14px 18px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.overlay .footer button { width: 100%; min-height: 58px; font-size: 18px; }

/* ---------- participant list ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 2px; cursor: pointer;
}
.list summary::-webkit-details-marker { display: none; }
.list .pname { font-weight: 700; }
.list .phash { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.list .detail { padding: 0 2px 14px; }

.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; min-height: 38px; padding: 6px; font-size: 14px; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.log { font-size: 14px; }
.log li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.log li:first-child { border-top: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

.preview { overflow-x: auto; font-size: 13px; }
.preview table { border-collapse: collapse; }
.preview th, .preview td { border: 1px solid var(--border); padding: 4px 8px; white-space: nowrap; }
.preview th.req { color: var(--ok); }

.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-wrap .card { width: 100%; max-width: 380px; }
