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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --text: #f0f0f0;
  --text-muted: #b8b8c8;
  --primary: #0f3460;
  --accent: #e94560;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 2rem;
}

header {
  text-align: center;
  padding: calc(1.5rem + env(safe-area-inset-top)) 1rem 0.5rem;
}

header h1 {
  font-size: 2.2rem;
  color: var(--accent);
  letter-spacing: 2px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.ai-badge {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #a8d8ff;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.25rem 0.85rem;
  border-radius: 2rem;
  margin-bottom: 1rem;
  letter-spacing: 0.5px;
}

nav {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid #444;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  min-width: 80px;
}

.nav-btn.active {
  background: var(--primary);
  color: var(--text);
  border-color: #2a6090;
}

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

.view { display: block; }
.view.hidden { display: none; }

/* Scan form */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

#source-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid #444;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 1rem;
}

textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid #444;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
}

textarea::placeholder { color: #666; }

#scan-btn {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
}

#scan-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Results */
.result { margin-top: 1rem; }

.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.result-card.error {
  border-left: 4px solid var(--accent);
  color: var(--accent);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.risk-badge {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: 1rem;
  color: white;
  font-weight: 700;
  font-size: 1rem;
}

.risk-badge.small { font-size: 0.9rem; padding: 0.25rem 0.65rem; }

.risk-score {
  font-size: 1.3rem;
  font-weight: 700;
}

.explanation { margin-bottom: 0.75rem; line-height: 1.6; font-size: 1rem; }

.patterns { margin-bottom: 0.75rem; }

.pattern-tag {
  display: inline-block;
  background: var(--primary);
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  font-size: 0.9rem;
  margin: 0.2rem;
}

.action { color: var(--text-muted); font-size: 1rem; line-height: 1.5; }

.btn-report-inline {
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
}

.ai-attribution {
  font-size: 0.85rem;
  color: #7ab8e8;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* AI source badges */
.ai-source {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 600;
}
.ai-source--edge  { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.ai-source--cloud { background: rgba(96,165,250,0.15); color: #7ab8e8; border: 1px solid rgba(96,165,250,0.3); }

/* "Verify with Cloud AI" button — shown for SAFE/LOW edge results */
.btn-verify-cloud {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  background: transparent;
  color: #7ab8e8;
  border: 1px solid rgba(96,165,250,0.4);
  border-radius: 1rem;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Scan counter in the header, below nav */
.scan-counter {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  min-height: 1em;
  letter-spacing: 0.3px;
}

/* Stats card in About view */
.stats-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.stats-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 0.6rem 0.5rem;
}
.stat-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  text-align: center;
}

/* History */
.history-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.history-header time { color: var(--text-muted); font-size: 0.9rem; }

.history-explanation {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.empty { color: var(--text-muted); text-align: center; padding: 2rem; }

/* About */
#view-about h2 { margin-bottom: 0.75rem; font-size: 1.4rem; }
#view-about h3 { margin: 1.25rem 0 0.5rem; color: var(--text-muted); font-size: 1.1rem; }
#view-about p, #view-about li { line-height: 1.7; margin-bottom: 0.4rem; }
#view-about ol, #view-about ul { padding-left: 1.5rem; }

.about-ai-box {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(100,180,255,0.07);
  border: 1px solid rgba(100,180,255,0.25);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}

.about-ai-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  line-height: 1;
}

.about-ai-box strong {
  display: block;
  color: #a8d8ff;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.about-ai-box p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.disclaimer { font-size: 0.9rem; color: var(--text-muted); margin-top: 1.5rem; font-style: italic; }
.app-version { font-size: 0.8rem; color: var(--text-muted); margin: -0.5rem 0 1rem; }

/* Alert banner */
.alert-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem;
  text-align: center;
  color: white;
  font-weight: 600;
  z-index: 100;
  transition: transform 0.3s;
}

.alert-banner.hidden { transform: translateY(100%); }

.hidden { display: none; }
.alert-banner.hidden { display: block; }


/* ── Toast notification ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: #2d2d2d;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.92rem;
  z-index: 9999;
  max-width: min(90vw, 420px);
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  pointer-events: none;
}
.toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}


/* =====================
   LANDING PAGE
   ===================== */

.hero {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.hero h2 {
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
  line-height: 1.35;
}
.hero p { color: var(--text-muted); font-size: 1rem; line-height: 1.7; }

.cta-box {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: rgba(100,180,255,0.07);
  border: 1px solid rgba(100,180,255,0.25);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.25rem;
}
.cta-icon { font-size: 1.8rem; flex-shrink: 0; line-height: 1; }
.cta-body strong {
  display: block;
  color: #a8d8ff;
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}
.cta-body p { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; margin: 0 0 0.6rem; }
.cta-steps { margin: 0.4rem 0 0.6rem 1.25rem; padding: 0; }
.cta-steps li { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 0.35rem; line-height: 1.55; }
.cta-note { font-size: 0.85rem; font-style: italic; }
.store-buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.2rem 0 0.8rem; }
.store-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #2a7fff 0%, #1a6bf0 100%);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  border: 1px solid rgba(255,255,255,0.15);
  transition: filter 0.15s ease;
}
.store-btn:hover { filter: brightness(1.1); }
.store-btn-sub { font-size: 0.7rem; font-weight: 400; opacity: 0.85; }
.store-btn.disabled {
  background: rgba(255,255,255,0.07);
  color: var(--text-muted);
  border-style: dashed;
  cursor: default;
  pointer-events: none;
}
code {
  background: rgba(255,255,255,0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.feature-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.25rem; }
.feature {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.feature-icon { font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
.feature strong { display: block; margin-bottom: 0.2rem; font-size: 1rem; }
.feature p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.55; margin: 0; }

/* Troll-likelihood breakdown in stats card */
.breakdown-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.breakdown-list { display: flex; flex-direction: column; gap: 0.35rem; }
.breakdown-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
}
.breakdown-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.breakdown-label { flex: 1; font-size: 0.95rem; }
.breakdown-count { font-weight: 700; color: var(--accent); }

#view-stats h2 { margin-bottom: 0.75rem; font-size: 1.4rem; }
