* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f5f7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1a1a1a;
  padding: 24px;
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 32px;
  width: 100%;
  max-width: 560px;
}

/* ---------- mode tabs ---------- */

.mode-tabs {
  display: flex;
  gap: 4px;
  background: #f1f2f5;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.mode-tab {
  flex: 1;
  margin: 0;
  padding: 9px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #666;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-tab.active {
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.subtitle {
  margin: 0 0 20px;
  color: #666;
  font-size: 14px;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  border: 2px dashed #c7c9cf;
  border-radius: 10px;
  cursor: pointer;
  padding: 16px;
  text-align: center;
  color: #666;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: #4f7cff;
}

.dropzone img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 6px;
}

.shot-wrap {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  border-radius: 6px;
  line-height: 0;
}

/* Setting `display` in a class always beats the browser's built-in
   `[hidden] { display: none }` rule (author styles win over user-agent
   styles regardless of specificity), so scope it to :not([hidden]) or the
   `hidden` attribute stops working on this element. */
.shot-wrap:not([hidden]) {
  display: inline-block;
}

.photo-crop-wrap {
  position: relative;
  width: 240px;
  max-width: 100%;
  height: 76px;
  margin: 0 auto 10px;
  background: #111;
  border: 2px solid #1a1a1a;
  border-radius: 6px;
  overflow: hidden;
}

.photo-crop-wrap img {
  position: absolute;
  opacity: 0;
  animation: crop-in 0.4s ease forwards;
}

button {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #4f7cff;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: #c7c9cf;
  cursor: not-allowed;
}

#result {
  margin-top: 20px;
  text-align: center;
}

.plate {
  display: inline-block;
  border: 3px solid #1a1a1a;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  background: #ffd12a;
}

.meta {
  margin-top: 10px;
  font-size: 13px;
  color: #666;
}

.error {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fdecea;
  color: #b3261e;
  font-size: 14px;
}

/* ---------- gate demo ---------- */

#reset-btn {
  background: #eceef2;
  color: #1a1a1a;
}

.gate-stage {
  margin-top: 16px;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b0d12;
  border-radius: 10px;
  overflow: hidden;
}

.video-wrap video,
.video-wrap img#frame-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.corner-brackets span {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(79, 255, 140, 0.85);
  opacity: 0.9;
}
.corner-brackets span:nth-child(1) { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.corner-brackets span:nth-child(2) { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.corner-brackets span:nth-child(3) { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.corner-brackets span:nth-child(4) { bottom: 10px; right: 10px; border-left: none; border-top: none; }

.scan-sweep {
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  top: -40%;
  background: linear-gradient(
    to bottom,
    rgba(79, 255, 140, 0) 0%,
    rgba(79, 255, 140, 0.35) 50%,
    rgba(79, 255, 140, 0) 100%
  );
  animation: sweep 2.2s linear infinite;
  pointer-events: none;
}

.scan-sweep.paused {
  animation-play-state: paused;
  opacity: 0;
}

@keyframes sweep {
  0% { top: -40%; }
  100% { top: 100%; }
}

.bbox {
  position: absolute;
  border: 2px solid #4fff8c;
  border-radius: 4px;
  box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.35), 0 0 16px rgba(79, 255, 140, 0.7);
  animation: bbox-pulse 1.1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes bbox-pulse {
  0%, 100% { box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.35), 0 0 8px rgba(79, 255, 140, 0.5); }
  50% { box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.35), 0 0 20px rgba(79, 255, 140, 0.95); }
}

.pipeline-steps {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  flex-direction: column;
  gap: 8px;
}

/* see the note on .shot-wrap above */
.pipeline-steps:not([hidden]) {
  display: flex;
}

.pipeline-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #aaa;
  transition: color 0.2s ease;
}

.pipeline-steps li .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d8dae0;
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.pipeline-steps li.active {
  color: #1a1a1a;
  font-weight: 600;
}

.pipeline-steps li.active .dot {
  background: #4f7cff;
  box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.18);
  animation: dot-pulse 0.9s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.pipeline-steps li.done {
  color: #2a9d5c;
}

.pipeline-steps li.done .dot {
  background: #2a9d5c;
  box-shadow: none;
  animation: none;
}

.plate-crop-wrap {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.plate-crop-wrap img {
  max-width: 100%;
  max-height: 110px;
  border-radius: 6px;
  border: 2px solid #1a1a1a;
  opacity: 0;
  transform: scale(0.85);
  animation: crop-in 0.4s ease forwards;
}

@keyframes crop-in {
  to { opacity: 1; transform: scale(1); }
}

.plate-decode {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  min-height: 44px;
}

.plate-decode .char {
  display: inline-block;
  min-width: 0.7ch;
}

.vehicle-card {
  margin-top: 16px;
  border: 1px solid #e5e6ea;
  border-radius: 10px;
  padding: 14px 16px;
  opacity: 0;
  transform: translateY(8px);
  animation: card-in 0.4s ease forwards;
}

@keyframes card-in {
  to { opacity: 1; transform: translateY(0); }
}

.vehicle-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid #f1f2f5;
}

.vehicle-row:last-child {
  border-bottom: none;
}

.vehicle-row span {
  color: #888;
}

.vehicle-row strong {
  text-align: right;
}

.gate-status {
  margin-top: 16px;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  opacity: 0;
  animation: card-in 0.4s ease forwards;
}

/* see the note on .shot-wrap above */
.gate-status:not([hidden]) {
  display: flex;
}

.gate-status.granted { background: #eafaf0; }
.gate-status.flagged { background: #fdecea; }
.gate-status.unknown { background: #f4f5f7; }

.status-text {
  font-weight: 700;
  font-size: 15px;
}

.gate-status.granted .status-text { color: #1e7e42; }
.gate-status.flagged .status-text { color: #b3261e; }
.gate-status.unknown .status-text { color: #555; }

.barrier {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.barrier .arm {
  position: absolute;
  left: 2px;
  top: 18px;
  width: 34px;
  height: 5px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, #d33 0 6px, #fff 6px 12px);
  transform-origin: left center;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gate-status.granted .barrier .arm {
  transform: rotate(-72deg);
}

.gate-status.flagged .barrier .arm {
  transform: rotate(0deg);
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}
