:root {
  --bg: #0b1020;
  --fg: #f5f6fa;
  --muted: #9aa0b4;
  --card: #141a2e;
  --accent: #4b7bff;
  --ok: #20c97b;
  --warn: #f5a524;
  --err: #e5484d;
  --block: #d14141;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top);
  --safe-bot: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0));
  z-index: 3;
}
.title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .3px;
}
.icon-btn {
  background: rgba(255,255,255,.08);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,.16); }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }

#video, #frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
#frame { display: none; }

.viewfinder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.reticle {
  width: min(70vw, 70vh, 320px);
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  box-shadow:
    0 0 0 9999px rgba(0,0,0,.45),
    inset 0 0 0 2px rgba(255,255,255,.85);
}

.scanner-hint {
  position: absolute;
  top: calc(var(--safe-top) + 64px);
  left: 0; right: 0;
  text-align: center;
  font-size: 14px;
  color: rgba(255,255,255,.85);
  text-shadow: 0 1px 2px rgba(0,0,0,.55);
  z-index: 2;
}

.scanner-controls {
  position: absolute;
  bottom: calc(var(--safe-bot) + 24px);
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 3;
}
.round-btn {
  width: 56px; height: 56px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.55);
  color: var(--fg);
  font-size: 22px;
  cursor: pointer;
}
.round-btn:active { background: rgba(0,0,0,.75); }

.list-status {
  position: absolute;
  top: calc(var(--safe-top) + 56px);
  right: 14px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(0,0,0,.45);
  padding: 4px 8px;
  border-radius: 8px;
  z-index: 3;
}
.list-status.warn { color: var(--warn); }
.list-status.err { color: var(--err); }

/* Result screen */
#result {
  background: var(--bg);
  padding: calc(var(--safe-top) + 56px) 18px calc(var(--safe-bot) + 18px);
  overflow-y: auto;
  z-index: 4;
}

.banner {
  border-radius: var(--radius);
  padding: 18px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3px;
  text-align: center;
  color: #0b1020;
  margin-bottom: 16px;
}
.banner.valid  { background: var(--ok); }
.banner.expired { background: var(--warn); }
.banner.revoked { background: var(--block); color: #fff; }
.banner.invalid { background: var(--err); color: #fff; }

.details {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 14px;
  row-gap: 6px;
  font-size: 15px;
}
.details dt {
  color: var(--muted);
  font-weight: 500;
}
.details dd {
  margin: 0;
  word-break: break-word;
}

.note {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
  line-height: 1.4;
}
.note .hl { color: var(--fg); }

.primary-btn {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 52px;
}
.primary-btn:active { filter: brightness(.92); }

.secondary-btn {
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}

/* Info panel */
.info-panel {
  position: absolute;
  right: 10px;
  top: calc(var(--safe-top) + 60px);
  max-width: 340px;
  width: calc(100% - 20px);
  background: var(--card);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 14px 16px;
  z-index: 5;
  box-shadow: 0 20px 40px rgba(0,0,0,.45);
}
.info-panel.hidden { display: none; }
.info-panel h2 {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
}
.info-panel p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--muted);
}
.info-panel .info-actions {
  margin-top: 10px;
}
.info-panel .info-footnote {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
