:root {
  --bg-a: #061a18;
  --bg-b: #0f3a2f;
  --panel: #f4f0e8;
  --ink: #10231f;
  --accent: #ff7a18;
  --accent-2: #19c6a7;
  --line: #d8cfc1;
  --ok: #157a52;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 18% 10%, #2e8f75 0%, transparent 36%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
}

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 16px 40px;
  display: grid;
  gap: 16px;
}

.topbar {
  color: #e7fff8;
}

.topbar h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar p {
  margin: 6px 0 0;
  opacity: 0.9;
}

.scanner-card,
.collection-card {
  background: var(--panel);
  border-radius: 18px;
  border: 2px solid #ffffff20;
  box-shadow: 0 14px 38px #00000030;
  padding: 14px;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 360px;
  border-radius: 14px;
  overflow: hidden;
  background: #101010;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay-card {
  position: absolute;
  inset: 10% 10%;
  border: 2px solid #ffffffbb;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px #00000033;
}

.overlay-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px dashed #ffffff99;
  border-radius: 12px;
}

.code-zone-label {
  position: absolute;
  top: -24px;
  right: 0;
  font-size: 12px;
  color: #ffffff;
  background: #00000070;
  border-radius: 999px;
  padding: 2px 8px;
}

.code-zone {
  position: absolute;
  top: 4%;
  right: 4%;
  width: 21%;
  height: 8.25%;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #ff7a1822;
}

.hidden-canvas {
  display: none;
}

.preview-title {
  margin: 12px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.72;
}

.preview-canvas {
  display: block;
  width: min(100%, 520px);
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.read-toast {
  margin-top: 8px;
  width: 100%;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  color: #ffffff;
  background: #157a52;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.read-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.status-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 2px;
}

.status-box-full {
  grid-column: 1 / -1;
}

.status-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.7;
}

#lastCode,
#ocrState {
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
}

#ocrRaw {
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  word-break: break-word;
}

.collection-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.collection-head h2 {
  margin: 0;
}

.collection-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.collection-head span {
  font-family: "IBM Plex Mono", monospace;
}

.btn-export {
  background: var(--accent-2);
  color: #06251f;
  font-size: 13px;
  padding: 8px 10px;
}

.code-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
}

.code-list li {
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent-2);
  background: #fffe;
  border-radius: 10px;
  padding: 8px 10px;
  font-family: "IBM Plex Mono", monospace;
  display: flex;
  justify-content: space-between;
}

.code-list time {
  opacity: 0.68;
  font-size: 12px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 2px 0;
  color: #dff6ef;
  font-size: 13px;
}

.app-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mail-link {
  font-family: "IBM Plex Mono", monospace;
}

@media (max-width: 680px) {
  .video-wrap {
    max-height: 300px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .collection-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .btn-export {
    font-size: 12px;
    padding: 7px 9px;
  }

  .app-footer {
    font-size: 12px;
    gap: 6px;
  }
}
