:root {
  --ink: #171717;
  --muted: #66615c;
  --line: #ded8d0;
  --paper: #f8f5f0;
  --panel: #ffffff;
  --accent: #125f7c;
  --accent-strong: #0d4a62;
  --success: #0e7a54;
  --danger: #a93535;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

.customer-body {
  height: 100svh;
  overflow: hidden;
  background: #050505;
}

.customer-shell {
  height: 100svh;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
}

.customer-card {
  position: relative;
  height: 100svh;
  overflow: hidden;
}

.customer-logo {
  position: fixed;
  left: 50%;
  top: auto;
  bottom: max(96px, 14svh);
  z-index: 3;
  width: min(22vw, 112px);
  height: auto;
  transform: translateX(-50%);
  pointer-events: none;
}

.is-scanning .customer-logo,
.has-match .customer-logo {
  display: none;
}

.customer-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 100svh;
  border-radius: 0;
  background: #050505;
  border: 0;
  box-shadow: none;
}

.customer-stage #camera,
.customer-stage #frame-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.matched-artwork {
  position: absolute;
  left: 50%;
  top: 45%;
  z-index: 1;
  width: min(86vw, 680px);
  max-height: 62svh;
  transform: translate(-50%, -50%);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.45);
}

.scan-message {
  position: fixed;
  left: 50%;
  bottom: max(34px, calc(env(safe-area-inset-bottom) + 18px));
  z-index: 3;
  min-height: 42px;
  width: auto;
  max-width: calc(100vw - 28px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.92);
  color: #050505;
  font-size: clamp(0.78rem, 3.8vw, 1rem);
  font-weight: 800;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.scan-message::after {
  content: "";
  width: 0.9em;
  text-align: left;
  animation: scan-dots 1.2s steps(4, end) infinite;
}

.scan-late .scan-message::after {
  display: none;
}

@keyframes scan-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}

.scan-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  padding: 22px;
  text-align: center;
  background: rgba(0, 0, 0, 0.16);
}

.scan-cta {
  width: min(82vw, 420px);
  min-height: 70px;
  border: 0;
  border-radius: 8px;
  padding: 0 24px;
  background: #ffffff;
  color: #050505;
  font-weight: 900;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

.scan-cta:hover {
  background: #f1f1f1;
}

.scan-again-button {
  position: fixed;
  left: 50%;
  top: max(18px, calc(env(safe-area-inset-top) + 12px));
  z-index: 6;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.9);
  color: #050505;
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  transform: translateX(-50%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.scan-again-button:hover {
  background: #ffffff;
}

.scan-timeout .scan-message {
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 70px));
  width: min(calc(100vw - 28px), 560px);
  min-height: 48px;
  white-space: nowrap;
  text-align: center;
  font-size: clamp(0.78rem, 3.5vw, 1rem);
}

.scan-timeout .scan-again-button {
  left: 50%;
  top: auto;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 10px));
  width: auto;
  min-width: 146px;
  height: 48px;
  padding: 0 22px;
  transform: translateX(-50%);
  font-size: 1rem;
}

.customer-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.customer-result {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.has-video-match .customer-result {
  inset: 0;
  z-index: 5;
  padding: 0;
  border-radius: 0;
  background: #050505;
  box-shadow: none;
  backdrop-filter: none;
}

.customer-result .result-type {
  display: none;
}

.customer-result .media-slot audio,
.customer-result .media-slot video {
  display: block;
  width: 100%;
}

.has-video-match .customer-result .media-slot,
.has-video-match .customer-result .media-slot video {
  width: 100%;
  height: 100svh;
}

.customer-result .media-slot video {
  max-height: 28svh;
  background: #050505;
}

.has-video-match .customer-result .media-slot video {
  max-height: none;
  object-fit: contain;
}

.customer-hidden-control {
  display: none !important;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 24px;
  align-items: start;
  padding: 32px 0;
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.admin-header h1 {
  font-size: 3rem;
}

.tab-bar {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eee8df;
  margin-bottom: 18px;
}

.tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab-button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(30, 26, 21, 0.08);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.scanner-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 20px 45px rgba(30, 26, 21, 0.07);
}

.brand-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 2.8rem, 3.1rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.prototype-pill,
.result-type {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf6f8;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.camera-stage {
  position: relative;
  overflow: hidden;
  min-height: 460px;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #1a1a1a;
  border: 1px solid #272727;
}

#camera,
#frame-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#frame-canvas {
  display: none;
}

.scanner-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #f8f5f0;
}

.scanner-empty span {
  color: rgba(248, 245, 240, 0.76);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.file-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.file-button {
  background: #eee8df;
  color: var(--ink);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.single-import-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fcfaf7;
}

.single-import-card .field-label {
  margin-top: 0;
}

.single-import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.warning-card {
  border-color: #e6c56a;
  background: #fff9e8;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.preflight-shell {
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
}

.preflight-drop {
  min-height: 260px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fcfaf7;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.preflight-drop span {
  color: var(--muted);
  max-width: 520px;
}

.preflight-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.field-label {
  display: block;
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 800;
}

.advanced-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fcfaf7;
}

.advanced-panel summary {
  cursor: pointer;
  font-weight: 800;
}

.text-field {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: white;
}

.status-card {
  margin-top: 14px;
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfaf7;
}

#status-label,
#score-label,
.result-empty,
.result-copy p {
  color: var(--muted);
  font-size: 0.92rem;
}

#match-label {
  font-size: 1.08rem;
}

.result-panel {
  position: sticky;
  top: 24px;
}

.result-empty {
  min-height: 128px;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fcfaf7;
}

.result-card {
  display: grid;
  gap: 14px;
}

.result-card img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f1eee9;
}

.result-copy {
  display: grid;
  gap: 8px;
}

.result-copy h3 {
  font-size: 1.5rem;
}

.media-slot audio,
.media-slot video {
  width: 100%;
  border-radius: 6px;
}

.media-slot video {
  background: #111;
  max-height: 420px;
}

.full-width {
  width: 100%;
}

.target-list {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.target-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.target-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fcfaf7;
  padding: 8px;
  display: grid;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}

.target-button:hover {
  border-color: var(--accent);
}

.target-button img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 4px;
}

.target-button span {
  font-size: 0.88rem;
  font-weight: 800;
}

.preflight-output {
  display: grid;
  gap: 14px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fcfaf7;
}

.detail-section h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.detail-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.detail-section li + li {
  margin-top: 6px;
}

.detail-section dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail-section dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-section dt {
  color: var(--muted);
}

.detail-section dd {
  margin: 0;
  font-weight: 800;
}

.folder-summary {
  margin-bottom: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fcfaf7;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.folder-table {
  overflow-x: auto;
}

.folder-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.folder-table th,
.folder-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.folder-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.matched {
  color: var(--success);
}

.not-matched {
  color: var(--danger);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    padding: 10px 0 24px;
  }

  .result-panel {
    position: static;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .camera-stage {
    min-height: 360px;
  }
}

@media (max-width: 560px) {
  .scanner-panel,
  .result-panel {
    padding: 14px;
  }

  .brand-row {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 2rem;
  }

  .admin-header {
    flex-direction: column;
  }

  .admin-header h1 {
    font-size: 2.2rem;
  }

  .tab-bar,
  .tab-button {
    width: 100%;
  }

  .camera-stage {
    min-height: 300px;
  }

  .controls,
  .primary-button,
  .secondary-button,
  .file-button {
    width: 100%;
  }

  .single-import-row {
    grid-template-columns: 1fr;
  }
}
