:root {
  --guide-blue: #2f8fe0;
  --guide-green: #2fbf8f;
  --guide-yellow: #e0c92f;
  --bg: #0b0d10;
  --panel: #14171c;
  --text: #eef1f4;
  --text-dim: #9aa3ad;
  --ok: #34d399;
  --bad: #f87171;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body, #app {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

.boot-splash {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
}
.boot-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid #2a2f36;
  border-top-color: var(--guide-blue);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Scanner shell ---------- */

.scanner-shell {
  position: relative;
  height: 100dvh;
  width: 100%;
  background: #000;
}

.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(1);
}

.camera-hidden-canvas {
  display: none;
}

/* ---------- Guide overlay (dashed card outline, matches target UI) ---------- */

.guide-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 24px;
}

.guide-frame {
  width: min(94vw, 520px);
  aspect-ratio: 8 / 5;
}

.guide-frame rect.outline {
  fill: none;
  stroke-width: 2;
  stroke-dasharray: 10 8;
  stroke-linecap: round;
  animation: dash-crawl 18s linear infinite;
}

.guide-frame .icon-shape {
  fill: none;
  stroke-width: 2.5;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
}

.guide-frame .field-line {
  fill: none;
  stroke-width: 3;
  stroke-dasharray: 10 8;
  stroke-linecap: round;
}

.guide-frame .scan-chevrons {
  opacity: 0.85;
}

@keyframes dash-crawl {
  to { stroke-dashoffset: -400; }
}

.scan-status-pill {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 23, 28, 0.72);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.scan-status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--guide-blue);
  animation: pulse 1.4s ease-in-out infinite;
}
.scan-status-pill.locked .dot { background: var(--ok); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ---------- Result sheet ---------- */

.debug-strip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  background: rgba(20, 23, 28, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text-dim);
  font-size: 11px;
}
.debug-strip .mono {
  font-family: "SF Mono", "Consolas", monospace;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
}
.model-loading-overlay p {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
}

.startup-error-banner {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  background: rgba(20, 23, 28, 0.92);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.startup-error-banner p {
  margin: 0;
  font-size: 13px;
  color: var(--bad);
  line-height: 1.5;
}
.startup-error-banner .btn { flex: none; padding: 8px 16px; }

.result-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 62dvh;
  background: var(--panel);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.45);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(.2,.8,.2,1);
  padding: 14px 18px 20px;
  overflow-y: auto;
}
.result-sheet.open { transform: translateY(0); }

.result-sheet .grabber {
  width: 40px; height: 4px; border-radius: 2px;
  background: #333a42;
  margin: 0 auto 14px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.result-header h2 { font-size: 16px; margin: 0; }

.validity-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.validity-badge.valid { background: rgba(52,211,153,0.15); color: var(--ok); }
.validity-badge.invalid { background: rgba(248,113,113,0.15); color: var(--bad); }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.field-grid .field-item.full { grid-column: 1 / -1; }

.field-item label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.field-item .field-value {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.field-item .check-icon.ok { color: var(--ok); }
.field-item .check-icon.bad { color: var(--bad); }

.result-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}
.btn {
  flex: 1;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1c2027;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.btn.primary {
  background: linear-gradient(135deg, var(--guide-blue), var(--guide-green));
  border: none;
}

#blazor-error-ui {
  display: none;
  background: #b91c1c;
  color: white;
  padding: 10px 14px;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 1000;
}
#blazor-error-ui .reload { color: white; text-decoration: underline; margin-left: 8px; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
