/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --bg-card: #1a1d2e;
  --bg-upload: #141725;
  --border: #2a2d42;
  --green: #2ecc71;
  --green-dark: #27ae60;
  --green-glow: rgba(46, 204, 113, 0.25);
  --text: #e8eaf6;
  --text-muted: #8892b0;
  --accent: #4ade80;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

.hidden { display: none !important; }

.brand-avatar {
  display: block;
  margin: 0 auto 12px;
  border-radius: 20px;
  object-fit: cover;
}

/* ─── Access gate ──────────────────────────────── */
.access-gate {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 24px;
  text-align: center;
}

.gate-icon {
  font-size: 56px;
}

.gate-text {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 280px;
}

/* ─── App wrapper ──────────────────────────────── */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Header ───────────────────────────────────── */
.header {
  text-align: center;
  padding-top: 8px;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #1a3a2a, #0d2318);
  border: 2px solid var(--green);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: 0 0 20px var(--green-glow);
}

.title {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green), #52d9a0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Upload zone ──────────────────────────────── */
.upload-section {
  width: 100%;
}

.upload-zone {
  background: var(--bg-upload);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 220px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--green);
  background: rgba(46, 204, 113, 0.05);
}

.upload-zone.has-image {
  border-style: solid;
  border-color: var(--green);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-placeholder {
  text-align: center;
  pointer-events: none;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-hint {
  color: var(--text-muted);
  font-size: 14px;
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 300px;
  display: block;
  pointer-events: none;
}

.upload-replace {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 17, 23, 0.85);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
}

/* ─── Attempts bar ─────────────────────────────── */
.attempts-bar {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.attempts-value {
  color: var(--green);
  font-weight: 600;
}

/* ─── CTA button ───────────────────────────────── */
.cta-section {
  width: 100%;
}

.btn-analyze {
  width: 100%;
  padding: 18px 24px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px var(--green-glow);
  letter-spacing: 0.2px;
}

.btn-analyze:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--green-glow);
}

.btn-analyze:active:not(:disabled) {
  transform: translateY(0);
}

.btn-analyze:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-icon {
  font-size: 18px;
}

/* ─── Loader ───────────────────────────────────── */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Result card ──────────────────────────────── */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-icon { font-size: 18px; }

.result-label { flex: 1; }

/* Confidence badge */
.confidence-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.confidence-badge.hidden { display: none; }
.badge-green  { background: rgba(46,204,113,0.15); color: var(--green); border: 1px solid rgba(46,204,113,0.3); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.badge-red    { background: rgba(239,68,68,0.15);  color: #f87171;       border: 1px solid rgba(239,68,68,0.3); }

/* Analysis text */
.analysis-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.analysis-section-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-top: 14px;
  margin-bottom: 4px;
  line-height: 1.4;
}
.analysis-section-header:first-child { margin-top: 0; }

.analysis-line {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 2px;
}

.analysis-confidence-line {
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  margin-top: 12px;
}

.disclaimer {
  display: none;
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.5;
}

.disclaimer.visible {
  display: block;
}

/* ─── Footer ───────────────────────────────────── */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding-top: 8px;
}

/* ─── Mobile tweaks ────────────────────────────── */
@media (max-width: 390px) {
  .title { font-size: 24px; }
  .btn-analyze { font-size: 16px; padding: 16px; }
}
