:root {
  --bg: #07070d;
  --bg-card: #11111c;
  --bg-elevated: #1a1a28;
  --pink: #ff2d78;
  --pink-soft: rgba(255,45,120,0.15);
  --cyan: #00f2ea;
  --cyan-soft: rgba(0,242,234,0.12);
  --purple: #8b5cf6;
  --gold: #ffd700;
  --text: #ffffff;
  --text-muted: #7070a0;
  --border: rgba(255,255,255,0.06);
  --glow-pink: 0 0 30px rgba(255,45,120,0.5), 0 0 60px rgba(255,45,120,0.2);
  --glow-cyan: 0 0 30px rgba(0,242,234,0.4), 0 0 60px rgba(0,242,234,0.15);
  --radius: 20px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Helvetica, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Layout ── */
.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ── Typography ── */
.gradient-text {
  background: linear-gradient(135deg, var(--pink) 0%, var(--purple) 50%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-title {
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  box-shadow: var(--glow-pink);
  width: 100%;
  font-size: 1.1rem;
  padding: 16px;
}
.btn-primary:not(:disabled):hover { box-shadow: var(--glow-pink), 0 8px 24px rgba(0,0,0,0.4); }

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 100%;
}

.btn-cyan {
  background: linear-gradient(135deg, var(--cyan), #0099ff);
  color: #000;
  box-shadow: var(--glow-cyan);
  width: 100%;
  font-size: 1.1rem;
  padding: 16px;
}

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed rgba(255,45,120,0.4);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
  background: var(--pink-soft);
}

.upload-zone.dragover,
.upload-zone:hover {
  border-color: var(--pink);
  background: rgba(255,45,120,0.1);
}

.upload-zone .icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
  animation: iconPulse 2.5s ease-in-out infinite;
}

.upload-zone p { color: var(--text-muted); font-size: 0.9rem; margin-top: 6px; }
.upload-zone strong { color: var(--text); font-size: 1rem; }

/* ── Preview Image ── */
.preview-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  display: none;
  aspect-ratio: 3/4;
  max-height: 360px;
}
.preview-wrap.show { display: block; }
.preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Scan Overlay ── */
.scan-overlay {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 2;
  pointer-events: none;
}
.scan-overlay.active { display: block; }

.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--pink), transparent);
  box-shadow: 0 0 12px var(--cyan), 0 0 24px var(--pink);
  animation: scanDown 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.scan-corners {
  position: absolute;
  inset: 12px;
  border: 2px solid transparent;
  border-radius: 12px;
  background:
    linear-gradient(var(--bg) 0 0) padding-box,
    linear-gradient(135deg, var(--cyan), var(--pink)) border-box;
  animation: cornerPulse 1.6s ease-in-out infinite;
}

.scan-label {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--cyan);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--cyan);
  white-space: nowrap;
  animation: labelBlink 1.2s step-end infinite;
}

/* ── Analysis Status Steps ── */
.status-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.status-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-elevated);
  font-size: 0.85rem;
  opacity: 0.3;
  transition: opacity 0.4s;
}
.status-step.active { opacity: 1; }
.status-step.done { opacity: 0.6; }
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-step.active .step-dot { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: dotPulse 1s ease-in-out infinite; }
.status-step.done .step-dot { background: #22c55e; }

/* ── Metrics ── */
.metric-item {
  display: flex;
  flex-direction: column;
  gap: 7px;
  opacity: 0;
  transform: translateY(16px);
  animation: slideUp 0.5s forwards;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-name {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.metric-score {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}
.metric-score.high { color: var(--cyan); }
.metric-score.low { color: var(--text-muted); }

.bar-track {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar-fill.high {
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  box-shadow: 0 0 8px rgba(0,242,234,0.4);
}
.bar-fill.low {
  background: linear-gradient(90deg, #2a2a40, #3a3a55);
}

/* ── Overall Score ── */
.overall-score-wrap {
  text-align: center;
  padding: 24px 0 8px;
}

.score-ring {
  width: 140px;
  height: 140px;
  margin: 0 auto 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring circle {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}
.ring-bg { stroke: var(--bg-elevated); }
.ring-fg {
  stroke-dasharray: 380;
  stroke-dashoffset: 380;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-fg.high { stroke: url(#ringGradient); filter: drop-shadow(0 0 6px var(--cyan)); }
.ring-fg.low { stroke: #3a3a55; }

.score-number {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-number.high { color: var(--cyan); text-shadow: 0 0 20px rgba(0,242,234,0.5); }
.score-number.low { color: var(--text-muted); }

.score-label { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px; }

.tier-badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 8px;
}
.tier-badge.high {
  background: linear-gradient(135deg, rgba(0,242,234,0.15), rgba(139,92,246,0.15));
  border: 1px solid rgba(0,242,234,0.4);
  color: var(--cyan);
  box-shadow: 0 0 16px rgba(0,242,234,0.2);
  animation: shimmer 2.5s linear infinite;
  background-size: 200% 100%;
}
.tier-badge.low {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Result Message ── */
.result-msg {
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0 8px;
  margin: 8px 0;
}
.result-msg.high { color: rgba(255,255,255,0.85); }
.result-msg.low { color: var(--text-muted); }

/* ── Confetti Canvas ── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

/* ── Loading Screen ── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  text-align: center;
}

.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--pink);
  border-right-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 18px; height: 18px;
  border-width: 2px;
}

/* ── Setup Photo Grid ── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: var(--bg-elevated);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .thumb-status {
  position: absolute;
  bottom: 4px; right: 4px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}
.thumb-status.ok { background: rgba(34,197,94,0.85); color: #fff; }
.thumb-status.fail { background: rgba(255,45,120,0.85); color: #fff; }
.thumb-status.pending { background: rgba(255,255,255,0.1); color: var(--text-muted); }

/* ── Utility ── */
.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.gap-3 { gap: 12px; }
.flex-col { display: flex; flex-direction: column; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* ── Keyframes ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes scanDown {
  0%   { top: -2px; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}
@keyframes cornerPulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}
@keyframes labelBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.1); }
}
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 4px var(--cyan); }
  50%       { box-shadow: 0 0 12px var(--cyan), 0 0 20px var(--cyan); }
}
@keyframes slideUp {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes popIn {
  0%   { transform: scale(0.7); opacity: 0; }
  70%  { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}
.pop-in { animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Notice ── */
.notice {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.5;
}
.notice-info {
  background: rgba(0,242,234,0.07);
  border: 1px solid rgba(0,242,234,0.2);
  color: rgba(0,242,234,0.8);
}
.notice-warn {
  background: rgba(255,200,0,0.07);
  border: 1px solid rgba(255,200,0,0.2);
  color: rgba(255,220,80,0.9);
}
.notice-success {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.3);
  color: rgba(100,230,130,0.9);
}
