:root {
  --bg: #0f172a;
  --card: #1e293b;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.header h1 {
  margin: 8px 0 4px;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* --- Live camera --- */
.camera {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #334155;
  background: #000;
  aspect-ratio: 3 / 4;
}

.camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reticle {
  position: absolute;
  inset: 18% 12%;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid var(--accent);
}
.corner.tl {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 8px;
}
.corner.tr {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 8px;
}
.corner.bl {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 8px;
}
.corner.br {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 8px;
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  text-align: center;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  padding: 0 12px;
}

/* --- Buttons --- */
.primary-btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 18px;
  font-size: 1.15rem;
  font-weight: 600;
  color: #00131f;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.3);
}
.primary-btn:active {
  transform: translateY(1px);
}
.primary-btn:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}
.primary-btn .icon {
  font-size: 1.4rem;
}

.secondary-btn {
  appearance: none;
  background: transparent;
  border: 1px solid #334155;
  color: var(--text);
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  cursor: pointer;
}

/* --- Status --- */
.status {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 6px;
}
.status.loading {
  color: var(--accent);
}
.status.error {
  color: var(--err);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Result --- */
.result {
  background: var(--card);
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}
.result-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.result-value {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 8px 0 16px;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  color: var(--ok);
}
.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.copy-btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 0.95rem;
  cursor: pointer;
}
.copy-btn.ghost {
  border-color: #334155;
  color: var(--text);
}

.raw {
  margin-top: 16px;
  text-align: left;
  color: var(--muted);
}
.raw summary {
  cursor: pointer;
  font-size: 0.85rem;
}
.raw pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  background: #0b1220;
  padding: 10px;
  border-radius: 8px;
  margin-top: 8px;
}

/* --- Fallback --- */
.fallback {
  background: var(--card);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
}
.fallback p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0;
}
