:root {
  --bg: #12141a;
  --panel: #1b1e27;
  --accent: #e8543f;
  --accent-dim: #7a2e24;
  --text: #f1f1f3;
  --text-dim: #9a9ca6;
  --ok: #3fbf6f;
  --warn: #e8b93f;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; /* no page scroll - the camera screen is the whole viewport */
}

button { font-family: inherit; cursor: pointer; }

/* ---------- Full-screen camera scan screen ---------- */
.scan-screen {
  position: fixed;
  inset: 0;
  padding: 0;
  overflow: hidden;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* fills the whole screen, cropping as needed */
  background: #000;
}

.scan-guide {
  position: absolute;
  inset: 22% 8% 30% 8%;
  border: 2px dashed rgba(255,255,255,0.55);
  border-radius: 14px;
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 14px 10px;
}
.topbar h1 { font-size: 1.2rem; margin: 0; }

.credits-bar {
  padding: 0 14px 10px;
  font-size: 0.85rem;
  color: var(--text);
  min-height: 18px;
}

.bottom-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent 100%);
}

.status {
  text-align: center;
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  min-height: 20px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.primary-btn {
  width: 100%;
  padding: 20px;
  border: none;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.primary-btn:disabled {
  background: #4a4d57;
  color: #9a9ca6;
  box-shadow: none;
}
.secondary-btn {
  width: 100%;
  padding: 14px;
  border: 1px solid #3a3f4d;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}
.ghost-btn {
  padding: 9px 14px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
}

/* ---------- Overlays (confirm / result) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
.confirm-card, .result-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
}
.confirm-label { color: var(--text-dim); margin: 10px 0 4px; }
.confirm-meta { color: var(--text-dim); font-size: 0.85rem; }
.confirm-actions { display: flex; gap: 10px; margin-top: 18px; }
.confirm-actions button { flex: 1; }

.confirm-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 4px;
}

.edit-input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #2a2e3a;
  background: #12141a;
  color: var(--text);
  font-size: 1rem;
  margin-top: 10px;
}

.type-toggle { display: flex; gap: 8px; margin-top: 10px; }
.type-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #2a2e3a;
  background: #12141a;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.type-btn.active { background: var(--accent-dim); color: var(--text); border-color: var(--accent); }

.result-icon { font-size: 2.6rem; margin-bottom: 8px; }
.result-message { color: var(--text-dim); white-space: pre-line; text-align: left; font-size: 0.9rem; }

/* ---------- Collection screen (not full-bleed) ---------- */
.screen:not(.scan-screen) {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
}
.hint { color: var(--text-dim); font-size: 0.85rem; }

.collection-header { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.collection-header input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #2a2e3a;
  background: var(--panel);
  color: var(--text);
}
.collection-list { list-style: none; padding: 0; margin-top: 10px; }
.collection-list li {
  padding: 12px 0;
  border-bottom: 1px solid #23262f;
  display: flex;
  gap: 12px;
  align-items: center;
}
.collection-list .thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #23262f;
}
.collection-list .title { font-weight: 500; }
.collection-list .meta { color: var(--text-dim); font-size: 0.8rem; }
