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

/* ── Dark palette (default) ── */
:root {
  --bg: #0a0e17;
  --card: rgba(22, 27, 40, 0.75);
  --card-solid: #161b28;
  --primary: #818cf8;
  --accent: #7c3aed;
  --blue: #3b82f6;
  --safe: #34d399;
  --safe-mid: #5bb5a2;
  --safe-low: #d4c9b5;
  --danger: #f87171;
  --danger-mid: #f59e0b;
  --danger-low: #fbbf24;
  --warning: #fbbf24;
  --text: #edeff3;
  --text-mid: #94a3b8;
  --text-dim: #64748b;
  --border: rgba(255, 255, 255, 0.06);
  --bracket: #34d399;
  --logo-bg: #0f1729;
  --radius: 18px;
  --glow: 0 4px 24px rgba(99, 102, 241, 0.12);
  --input-bg: rgba(255, 255, 255, 0.015);
  --scan-dash: rgba(255, 255, 255, 0.08);
  --bar-bg: rgba(255, 255, 255, 0.06);
  --doc-line: rgba(255, 255, 255, 0.06);
  --glow1: rgba(124, 58, 237, 0.10);
  --glow2: rgba(59, 130, 246, 0.08);
  --logo-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 0 50px rgba(245,237,224,0.06), 0 8px 40px rgba(0,0,0,0.30);
  --toast-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ── Light palette ── */
[data-theme="light"] {
  --bg: #F5F0E8;
  --card: rgba(255, 255, 255, 0.85);
  --card-solid: #ffffff;
  --primary: #6366f1;
  --accent: #7c3aed;
  --blue: #3b82f6;
  --safe: #16a34a;
  --safe-mid: #3d9970;
  --safe-low: #8c7e6a;
  --danger: #dc2626;
  --danger-mid: #d97706;
  --danger-low: #ca8a04;
  --warning: #d97706;
  --text: #1a1a2e;
  --text-mid: #4a5568;
  --text-dim: #718096;
  --border: rgba(0, 0, 0, 0.07);
  --bracket: #16a34a;
  --logo-bg: #F5EDE0;
  --input-bg: rgba(0, 0, 0, 0.02);
  --scan-dash: rgba(0, 0, 0, 0.10);
  --bar-bg: rgba(0, 0, 0, 0.06);
  --doc-line: rgba(0, 0, 0, 0.08);
  --glow1: rgba(124, 58, 237, 0.05);
  --glow2: rgba(59, 130, 246, 0.04);
  --logo-shadow: 0 0 0 1px rgba(0,0,0,0.04), 0 4px 20px rgba(0,0,0,0.08);
  --toast-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}


/* ── Base ── */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }


/* ── Ambient glow ── */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  transition: background 0.3s ease;
}

.bg-glow.glow-1 {
  top: -20%;
  left: -10%;
  width: 560px;
  height: 560px;
  background: radial-gradient(circle, var(--glow1) 0%, transparent 70%);
}

.bg-glow.glow-2 {
  top: -8%;
  right: -12%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, var(--glow2) 0%, transparent 70%);
}


/* ── Page ── */
.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 1;
}


/* ── Header ── */
.app-header {
  text-align: center;
  padding: 20px 0 0;
  position: relative;
}

.header-logo {
  width: clamp(100px, 22vw, 130px);
  height: clamp(100px, 22vw, 130px);
  margin: 0 auto 16px;
  border-radius: 24px;
  overflow: hidden;
  background: var(--logo-bg);
  box-shadow: var(--logo-shadow);
  transition: box-shadow 0.3s ease, transform 0.2s ease;
  cursor: pointer;
}

.header-logo:hover {
  transform: scale(1.04);
}

.header-logo:active {
  transform: scale(0.97);
}

.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-tagline {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
}




/* ── Cards ── */
.card {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  transition: background 0.3s ease, border-color 0.3s ease;
}


/* ── Main input card ── */
.main-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}


/* ── Buttons ── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), #6366f1, var(--blue));
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.20);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
  text-align: center;
  margin-top: auto;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.30);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-outline {
  display: block;
  width: 100%;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: transparent;
  border: 1.5px solid rgba(129, 140, 248, 0.3);
  border-radius: 14px;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-outline:hover {
  background: rgba(129, 140, 248, 0.08);
  border-color: var(--primary);
}

.btn-sm {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn-sm:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.28);
}


/* ── Mode toggle ── */
.mode-toggle {
  display: flex;
  background: var(--input-bg);
  border-radius: 14px;
  padding: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.mode-btn {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border-radius: 11px;
  transition: all 0.2s ease;
  text-align: center;
  letter-spacing: -0.01em;
}

.mode-btn.active {
  background: rgba(129, 140, 248, 0.14);
  color: var(--primary);
  box-shadow: 0 1px 6px rgba(99, 102, 241, 0.10);
}


/* ── Upload / paste ── */
.upload-section {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.upload-section.hidden { display: none; }

.paste-section {
  display: none;
  flex: 1;
  flex-direction: column;
}

.paste-section.active { display: flex; }

.scan-area {
  position: relative;
  border: 2px dashed var(--scan-dash);
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  background: var(--input-bg);
  flex: 1;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.scan-area:hover {
  border-color: rgba(129, 140, 248, 0.3);
  background: rgba(99, 102, 241, 0.03);
}

.scan-area.drag-over {
  border-color: var(--primary);
  border-style: solid;
  background: rgba(99, 102, 241, 0.06);
  box-shadow: inset 0 0 30px rgba(99, 102, 241, 0.04);
}

.scan-area.has-file {
  border-style: solid;
  border-color: rgba(129, 140, 248, 0.3);
  background: rgba(99, 102, 241, 0.03);
  padding: 20px;
}

.upload-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.20);
}

.upload-icon svg { width: 22px; height: 22px; fill: white; }

.upload-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.upload-hint {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.file-preview { display: none; width: 100%; text-align: center; }
.file-preview.active { display: block; }
.file-preview img { max-height: 260px; border-radius: 10px; object-fit: contain; margin: 0 auto; }
.file-name { font-size: 12px; font-weight: 600; color: var(--primary); margin-top: 8px; }

.remove-btn {
  font-size: 12px;
  color: var(--danger);
  font-weight: 600;
  margin-top: 12px;
  display: none;
  background: none;
  border: none;
  text-align: center;
  width: 100%;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.remove-btn:hover { opacity: 0.7; }
.remove-btn.active { display: block; }

.paste-area {
  width: 100%;
  flex: 1;
  min-height: 260px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background: var(--input-bg);
  resize: none;
  outline: none;
  transition: border-color 0.2s ease;
}

.paste-area:focus { border-color: rgba(129, 140, 248, 0.35); }
.paste-area::placeholder { color: var(--text-dim); }

input[type="file"] { display: none; }


/* ── Corner brackets ── */
.scan-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  transition: border-color 0.2s ease;
}

.scan-corner.tl { top: 10px;    left: 10px;   border-top: 2px solid var(--bracket); border-left: 2px solid var(--bracket);   border-radius: 3px 0 0 0; }
.scan-corner.tr { top: 10px;    right: 10px;  border-top: 2px solid var(--bracket); border-right: 2px solid var(--bracket);  border-radius: 0 3px 0 0; }
.scan-corner.bl { bottom: 10px; left: 10px;   border-bottom: 2px solid var(--bracket); border-left: 2px solid var(--bracket);  border-radius: 0 0 0 3px; }
.scan-corner.br { bottom: 10px; right: 10px;  border-bottom: 2px solid var(--bracket); border-right: 2px solid var(--bracket); border-radius: 0 0 3px 0; }

.drag-over .scan-corner { border-color: var(--primary); }


/* ── Scanning animation ── */
.scanning-overlay { display: none; }
.scanning-overlay.active { display: block; }
.scanning-card { padding: 36px 24px; }

.scanner-frame {
  width: 150px;
  height: 150px;
  margin: 4px auto 20px;
  position: relative;
}

.scanner-frame .scan-corner { width: 24px; height: 24px; }
.scanner-frame .scan-corner.tl { top: 0;    left: 0;  border-width: 3px; }
.scanner-frame .scan-corner.tr { top: 0;    right: 0; border-width: 3px; }
.scanner-frame .scan-corner.bl { bottom: 0; left: 0;  border-width: 3px; }
.scanner-frame .scan-corner.br { bottom: 0; right: 0; border-width: 3px; }

.scan-beam {
  position: absolute;
  left: 14%;
  width: 72%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: beam 2s ease-in-out infinite;
}

@keyframes beam {
  0%, 100% { top: 10%; opacity: 0.5; }
  50%      { top: 85%; opacity: 1;   }
}

.scanner-doc {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 90px;
  background: var(--card-solid);
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}

.doc-line { height: 4px; background: var(--doc-line); border-radius: 2px; }
.doc-line:nth-child(2) { width: 65%; }
.doc-line:nth-child(3) { width: 80%; }
.doc-line:nth-child(4) { width: 50%; }

.scanning-label {
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  letter-spacing: -0.02em;
}

.scanning-sub {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 4px;
}


/* ── Results ── */
.results-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.verdict-card {
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
  border: 1px solid transparent;
}

.verdict-card.safe    { background: rgba(52, 211, 153, 0.06);  border-color: rgba(52, 211, 153, 0.15); }
.verdict-card.danger  { background: rgba(248, 113, 113, 0.06); border-color: rgba(248, 113, 113, 0.15); }
.verdict-card.warning { background: rgba(251, 191, 36, 0.06);  border-color: rgba(251, 191, 36, 0.15); }

[data-theme="light"] .verdict-card.safe    { background: rgba(22, 163, 74, 0.06);  border-color: rgba(22, 163, 74, 0.18); }
[data-theme="light"] .verdict-card.danger  { background: rgba(220, 38, 38, 0.05);  border-color: rgba(220, 38, 38, 0.15); }
[data-theme="light"] .verdict-card.warning { background: rgba(217, 119, 6, 0.06);  border-color: rgba(217, 119, 6, 0.15); }

.verdict-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin-bottom: 14px;
}

.verdict-card.safe .verdict-badge    { background: var(--safe); box-shadow: 0 4px 16px rgba(52, 211, 153, 0.20); }
.verdict-card.danger .verdict-badge  { background: var(--danger); box-shadow: 0 4px 16px rgba(248, 113, 113, 0.20); }
.verdict-card.warning .verdict-badge { background: var(--warning); box-shadow: 0 4px 16px rgba(251, 191, 36, 0.20); }
.verdict-badge svg { width: 26px; height: 26px; fill: white; }

.verdict-title {
  font-size: 21px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.verdict-card.safe .verdict-title    { color: var(--safe); }
.verdict-card.danger .verdict-title  { color: var(--danger); }
.verdict-card.warning .verdict-title { color: var(--warning); }

.verdict-explanation {
  font-size: 14px;
  font-weight: 500;
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.6;
  color: var(--text-mid);
}


/* ── Likelihood bar ── */
.likelihood-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.likelihood-label { font-weight: 700; font-size: 13px; letter-spacing: -0.01em; }

.likelihood-value {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.bar-track { height: 6px; background: var(--bar-bg); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }


/* ── Confidence factors + red flags ── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-mid);
}

.factor-row, .flag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.factor-row:last-child, .flag-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.factor-direction {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.factor-direction.scam { background: rgba(248, 113, 113, 0.10); color: var(--danger); }
.factor-direction.safe { background: rgba(52, 211, 153, 0.10);  color: var(--safe); }
[data-theme="light"] .factor-direction.scam { background: rgba(220, 38, 38, 0.08); }
[data-theme="light"] .factor-direction.safe { background: rgba(22, 163, 74, 0.08); }

.factor-label { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }

.factor-impact {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
}

/* Scam direction: low=yellow, medium=orange, high=red */
.factor-row.scam .factor-impact.low    { background: rgba(251, 191, 36, 0.12);  color: var(--danger-low); }
.factor-row.scam .factor-impact.medium { background: rgba(245, 158, 11, 0.12);  color: var(--danger-mid); }
.factor-row.scam .factor-impact.high   { background: rgba(248, 113, 113, 0.12); color: var(--danger); }

/* Safe direction: low=cream, medium=teal, high=green */
.factor-row.safe .factor-impact.low    { background: rgba(212, 201, 181, 0.12); color: var(--safe-low); }
.factor-row.safe .factor-impact.medium { background: rgba(91, 181, 162, 0.12);  color: var(--safe-mid); }
.factor-row.safe .factor-impact.high   { background: rgba(52, 211, 153, 0.12);  color: var(--safe); }

[data-theme="light"] .factor-row.scam .factor-impact.low    { background: rgba(202, 138, 4, 0.10); }
[data-theme="light"] .factor-row.scam .factor-impact.medium { background: rgba(217, 119, 6, 0.10); }
[data-theme="light"] .factor-row.scam .factor-impact.high   { background: rgba(220, 38, 38, 0.10); }
[data-theme="light"] .factor-row.safe .factor-impact.low    { background: rgba(140, 126, 106, 0.10); }
[data-theme="light"] .factor-row.safe .factor-impact.medium { background: rgba(61, 153, 112, 0.10); }
[data-theme="light"] .factor-row.safe .factor-impact.high   { background: rgba(22, 163, 74, 0.10); }

.flag-row { align-items: flex-start; }

.flag-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 7px;
}

.flag-dot.high   { background: var(--danger); }
.flag-dot.medium { background: var(--warning); }
.flag-text { font-size: 14px; font-weight: 500; }


/* ── Advice ── */
.advice-card {
  background: rgba(129, 140, 248, 0.05);
  border: 1px solid rgba(129, 140, 248, 0.10);
  border-radius: var(--radius);
  padding: 18px;
}

[data-theme="light"] .advice-card {
  background: rgba(99, 102, 241, 0.04);
  border-color: rgba(99, 102, 241, 0.12);
}

.advice-label {
  font-weight: 700;
  font-size: 11px;
  color: var(--primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.advice-body { font-size: 14px; font-weight: 500; line-height: 1.6; color: var(--text-mid); }


/* ── Actions ── */
.actions-row { display: flex; gap: 10px; }
.actions-row .btn-outline,
.actions-row .btn-primary { flex: 1; font-size: 14px; padding: 12px 16px; margin-top: 0; }


/* ── Quick URL check ── */
.url-check-card { flex-shrink: 0; }

.url-check-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.url-check-row { display: flex; gap: 8px; }

.url-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.2s ease;
}

.url-input:focus { border-color: rgba(129, 140, 248, 0.35); }
.url-input::placeholder { color: var(--text-dim); }

.url-result { margin-top: 10px; display: none; }
.url-result.active { display: block; }

.url-verdict {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.url-verdict.safe    { color: var(--safe);    background: rgba(52, 211, 153, 0.08); }
.url-verdict.warning { color: var(--warning); background: rgba(251, 191, 36, 0.08); }
.url-verdict.danger  { color: var(--danger);  background: rgba(248, 113, 113, 0.08); }

.url-verdict + .url-flag { margin-top: 8px; }

.url-loading {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  padding: 4px 0;
}

.url-flag {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 5px 0;
  font-size: 13px;
  font-weight: 500;
}

.url-safe { color: var(--safe); font-weight: 600; font-size: 13px; padding: 5px 0; }


/* ── Error ── */
.error-msg {
  display: none;
  background: rgba(248, 113, 113, 0.06);
  border: 1px solid rgba(248, 113, 113, 0.14);
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  text-align: center;
  flex-shrink: 0;
}

.error-msg.active { display: block; }


/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--card-solid);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1000;
  pointer-events: none;
  box-shadow: var(--toast-shadow);
}

.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ── Disclaimer ── */
.disclaimer {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
  padding: 4px 8px;
}


/* ── Footer ── */
.app-footer {
  text-align: center;
  padding: 4px 0;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  flex-shrink: 0;
  line-height: 1.6;
}


/* ── Responsive ── */
@media (max-width: 600px) {
  .page { padding: 16px 16px; gap: 16px; }
  .card { padding: 20px; }
  .scan-area { min-height: 220px; padding: 32px 16px; }
  .paste-area { min-height: 220px; }
  .actions-row { flex-direction: column; }
  .verdict-card { padding: 22px 18px; }
}
