:root {
  --bg: #0f4c81;
  --bg-dark: #0a3760;
  --accent: #00c896;
  --danger: #e5484d;
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.72);
  --panel: rgba(255, 255, 255, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-dark) 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

header {
  text-align: center;
}

header h1 {
  font-size: 1.4rem;
  margin: 0 0 0.25rem;
}

header p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.stage {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.stage.scanning video {
  display: block;
}

.stage .placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-dim);
  padding: 2rem;
  text-align: center;
}

.stage.scanning .placeholder,
.stage.success .placeholder,
.stage.error .placeholder,
.stage.submitting .placeholder {
  display: none;
}
.stage.idle .placeholder {
  display: flex;
}

.result-panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
  overflow-y: auto;
}

.stage.submitting .result-panel.submitting,
.stage.success .result-panel.success,
.stage.error .result-panel.error {
  display: flex;
}

.icon {
  font-size: 3rem;
  line-height: 1;
}

.gtin-readout {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
  word-break: break-all;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.event-summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.event-raw {
  width: 100%;
  max-width: 320px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.event-raw summary {
  cursor: pointer;
  color: var(--text);
}

.event-raw pre {
  margin: 0.5rem 0 0;
  max-height: 8rem;
  overflow: auto;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--text);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button.primary {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: #043027;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
}

button.primary:active {
  transform: scale(0.98);
}

button.secondary {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 0.7rem 1.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.error .icon {
  color: var(--danger);
}

.success .icon {
  color: var(--accent);
}

footer {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-align: center;
}

.hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2em;
}
