* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #000; color: #fff;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}
#app { position: relative; width: 100%; height: 100%; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  background: #000;
}
.screen.active { display: flex; }

/* ---------- Camera screen ---------- */
#screen-camera { align-items: center; justify-content: flex-end; }
#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #111;
}
.info-badge {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: #fff; font-weight: bold; font-size: 18px;
  padding: 8px 16px; border-radius: 8px;
  white-space: pre-line; z-index: 2;
  max-width: 92vw; text-align: center;
  line-height: 1.35;
}
.capture-btn {
  position: relative; z-index: 2;
  margin-bottom: 40px;
  padding: 16px 40px;
  font-size: 18px; font-weight: bold;
  color: #fff; background: #C62828;
  border: none; border-radius: 32px;
  letter-spacing: 1px;
}
.capture-btn:active { filter: brightness(0.85); }
.capture-btn:disabled { background: #555; }

/* ---------- Editor screen ---------- */
#screen-editor { background: #000; }
.editor-canvas-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  min-height: 0;
  touch-action: none;
}
#annCanvas {
  max-width: 100%; max-height: 100%;
  touch-action: none;
  background: #000;
}
.bottom-bar {
  background: rgba(0,0,0,0.85);
  padding: 12px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.hint {
  color: #fff; font-weight: bold; font-size: 15px;
  text-align: center; margin-bottom: 2px;
}
.company-row, .row2, .row3 {
  display: flex; gap: 8px;
}
.bottom-bar [hidden] { display: none !important; }
.company-row button, .row3 button { flex: 1; }
button {
  font-family: inherit;
  border: none; border-radius: 8px;
  padding: 12px 10px; font-size: 14px; font-weight: 600;
  color: #fff; background: #333;
  cursor: pointer;
}
button:active { filter: brightness(0.85); }
.btn-secondary { background: #444; flex: 1; }
.btn-primary { background: #2E7D32; flex: 2; }
.btn-delete { background: #C62828; width: 100%; }

/* ---------- Settings screen ---------- */
#screen-settings { background: #111; }
.settings-scroll {
  flex: 1; overflow-y: auto; padding: 20px;
}
.settings-scroll h2 { margin-top: 0; }
.settings-scroll h3 { margin-bottom: 8px; }
.settings-scroll hr { border: none; border-top: 1px solid #333; margin: 20px 0; }
.settings-scroll label {
  display: block; margin-top: 14px; margin-bottom: 4px; font-size: 14px; color: #ccc;
}
.settings-scroll input[type="range"] { width: 100%; }
.preview-box {
  background: #000; border-radius: 8px; padding: 16px;
  text-align: center; margin-bottom: 20px;
}
#previewText { font-weight: bold; }
.swatch-row {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 10px 0;
}
.swatch {
  width: 36px; height: 36px; border-radius: 50%;
  flex-shrink: 0; border: 1px solid #777; cursor: pointer;
}
.swatch.selected { border: 3px solid #2196F3; }
#btnSettingsDone { width: 100%; margin-top: 24px; padding: 14px; font-size: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,20,0.95); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 14px;
  max-width: 85vw; text-align: center;
  opacity: 0; pointer-events: none; z-index: 100;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
