/* Bulk QR Code Scanner — mobile-first, standalone */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --primary: #0f766e;
  --primary-hover: #0d9488;
  --primary-text: #ffffff;
  --secondary: #e2e8f0;
  --secondary-hover: #cbd5e1;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-text: #ffffff;
  --ok-bg: #dcfce7;
  --ok-border: #16a34a;
  --ok-text: #14532d;
  --warn-bg: #fef3c7;
  --warn-border: #d97706;
  --warn-text: #78350f;
  --err-bg: #fee2e2;
  --err-border: #dc2626;
  --err-text: #7f1d1d;
  --info-bg: #e0f2fe;
  --info-border: #0284c7;
  --info-text: #0c4a6e;
  --focus: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --max: 40rem;
  --tap: 48px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.page {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.4rem, 5vw, 1.75rem);
  line-height: 1.2;
}

.lede {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.98rem;
}

.privacy {
  margin: 0;
  padding: 0.65rem 0.8rem;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 8px;
  color: var(--info-text);
  font-size: 0.88rem;
}

.banner {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.banner-error {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-text);
}

.scanner-panel,
.results-panel {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.status-wrap {
  margin-bottom: 0.75rem;
}

.status {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-word;
}

.status-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.status-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.status-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.status-error {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-text);
}

.reader-shell {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: #0f172a;
  aspect-ratio: 3 / 4;
  max-height: min(62vh, 28rem);
}

.reader-shell[data-feedback="ok"] {
  outline: 3px solid var(--ok-border);
  outline-offset: 2px;
}

.reader-shell[data-feedback="warn"] {
  outline: 3px solid var(--warn-border);
  outline-offset: 2px;
}

.reader-shell[data-feedback="error"] {
  outline: 3px solid var(--err-border);
  outline-offset: 2px;
}

.reader {
  width: 100%;
  height: 100%;
}

.reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 10px;
}

.reader img {
  display: none !important;
}

/* Hide library chrome we don't need */
#reader__dashboard_section,
#reader__header_message,
#reader__scan_region > img {
  display: none !important;
}

.scan-frame {
  position: absolute;
  inset: 18% 14%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 999px rgba(15, 23, 42, 0.28);
}

.camera-controls {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.75rem;
}

.camera-select-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.camera-select {
  width: 100%;
  min-height: var(--tap);
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn-row-wrap {
  margin-top: 0.85rem;
}

.btn {
  min-height: var(--tap);
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  flex: 1 1 calc(50% - 0.6rem);
  touch-action: manipulation;
}

.btn:focus-visible,
.camera-select:focus-visible,
.pin-list:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--danger-text);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.results-meta {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.results-meta h2 {
  margin: 0;
  font-size: 1.15rem;
}

.count-line,
.last-line {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.98rem;
}

.label {
  color: var(--muted);
}

.count,
.last-pin {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.last-pin {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  word-break: break-all;
  text-align: right;
}

.textarea-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.pin-list {
  width: 100%;
  min-height: 14rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1rem;
  line-height: 1.5;
  background: #fff;
  color: var(--text);
}

.confirm {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--err-border);
  border-radius: 10px;
  background: var(--err-bg);
  color: var(--err-text);
}

.confirm p {
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.footer {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.footer p {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 640px) {
  .page {
    padding: 1.5rem 1.25rem 3rem;
  }

  .reader-shell {
    aspect-ratio: 4 / 3;
    max-height: 24rem;
  }

  .btn {
    flex: 0 1 auto;
    min-width: 8.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
