:root {
  --bg: #10151C;
  --surface: #1B232E;
  --surface-2: #222C39;
  --border: #2C3846;
  --text: #EDEFF2;
  --text-dim: #93A1AF;
  --teal: #5EEAD4;
  --teal-dim: #3A8F82;
  --amber: #F5B942;
  --coral: #FF7A70;
  --sage: #8FD9A8;
  --violet: #B39DFF;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

h1, h2 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }

.hidden, .hidden-canvas { display: none !important; }

/* ---------- View switching ---------- */
.view {
  display: none;
  min-height: 100vh;
  width: 100%;
}
.view--active { display: flex; }

.wrap {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wrap--center {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  text-align: center;
  gap: 22px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--teal);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  margin: 0;
}

/* ---------- Brandmark ---------- */
.brandmark { display: flex; justify-content: center; margin-top: 8px; }
.mark-svg { width: 84px; height: 84px; }
.mark-ring { fill: none; stroke: var(--teal); stroke-width: 3; opacity: 0.9; }
.mark-eye { fill: var(--surface); stroke: var(--teal); stroke-width: 3; }
.mark-pupil { fill: var(--teal); }
.mark-sweep { stroke: var(--amber); stroke-width: 3; stroke-linecap: round; }
.mark-sweep-dot { fill: var(--amber); }

#view-welcome h1 { font-size: 34px; text-align: center; }
#view-welcome .eyebrow { text-align: center; margin-bottom: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
}
.card h2 { font-size: 15px; margin-bottom: 10px; }

.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.check-list li { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot--camera { background: var(--teal); }
.dot--bt { background: var(--amber); }
.dot--audio { background: var(--violet); }
.dot--mag { background: var(--sage); }

.card--honest { background: var(--surface-2); }
.card--honest p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-dim); }
.card--honest strong { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  border-radius: 999px;
  padding: 15px 22px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn--full { width: 100%; }
.btn--primary { background: var(--teal); color: #0A1512; }
.btn--ghost { background: transparent; color: var(--text-dim); }
.btn--small { padding: 10px 16px; font-size: 13.5px; }
.btn--share { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn__icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Home / Scan button ---------- */
.home-title { font-size: 30px; margin-top: -6px; }
.home-sub { color: var(--text-dim); font-size: 14.5px; line-height: 1.5; max-width: 320px; }

.scan-button {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 50% 40%, #1E2A2F, var(--surface) 70%);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}
.scan-button__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--teal-dim);
  animation: pulse-ring 2.6s ease-out infinite;
}
.scan-button__ring::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid var(--teal-dim);
  opacity: 0.6;
}
.scan-button__label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  z-index: 1;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(94,234,212,0.35); }
  70% { box-shadow: 0 0 0 22px rgba(94,234,212,0); }
  100% { box-shadow: 0 0 0 0 rgba(94,234,212,0); }
}

/* ---------- Scanning stage ---------- */
.scan-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #000;
  overflow: hidden;
}
#camera-feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.scan-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 20px 20px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
}
.scan-progress {
  height: 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.18);
  overflow: hidden;
  margin-bottom: 10px;
}
.scan-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width 0.4s ease;
}
.scan-step-label {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0;
  text-align: center;
  color: #FFFFFF;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

/* ---------- Audio visualizer ---------- */
.audio-viz {
  position: absolute;
  left: 20px; right: 20px; bottom: 96px;
  background: rgba(16, 21, 28, 0.97); /* near-solid so text stays readable */
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.audio-viz-label { margin: 0 0 12px; font-size: 13.5px; color: var(--text); }
.eq { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 48px; }
.eq-bar {
  width: 6px;
  height: 6%;
  background: linear-gradient(to top, var(--violet), var(--teal));
  border-radius: 3px;
  transition: height 0.08s linear;
}

/* ---------- On-device AI overlay ---------- */
#ai-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ai-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #FFFFFF;
  text-align: center;
  margin: 8px auto 0;
  width: fit-content;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(16, 21, 28, 0.92);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}
.ai-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 13px;
  border-radius: 999px;
  background: #0E131B;            /* solid, non-transparent */
  color: #FFFFFF;                 /* white text */
  border: 1px solid rgba(179, 157, 255, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.finding-ai {
  font-size: 12px;
  color: var(--violet);
  margin: 6px 0 0;
}

/* ---------- "Who's on this WiFi?" router check ---------- */
.card--router { width: 100%; text-align: left; }
.router-sub { font-size: 13px; color: var(--text-dim); margin: 0 0 12px; line-height: 1.5; }
.router-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.router-gw {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 13px;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.router-gw:active { transform: scale(0.97); }
.router-note { font-size: 12px; color: var(--text-dim); margin: 0; line-height: 1.55; }
.mono { font-family: var(--font-mono); color: var(--teal); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  background: rgba(34, 44, 57, 0.98);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 86vw;
  text-align: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.toast--show {
  opacity: 1;
  visibility: visible;
}

.btn-cancel {
  position: absolute;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 14px;
  font-family: var(--font-body);
}

/* ---------- Results ---------- */
.result-banner { text-align: center; padding: 12px 0 4px; }
.result-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.result-icon--clear { background: rgba(143,217,168,0.15); }
.result-icon--caution { background: rgba(245,185,66,0.15); }
.result-icon--alert { background: rgba(255,122,112,0.15); }
.result-title { font-size: 26px; margin-bottom: 8px; }
.result-sub { color: var(--text-dim); font-size: 14.5px; line-height: 1.5; margin: 0; }

.findings-list { display: flex; flex-direction: column; gap: 12px; }
.finding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  gap: 12px;
}
.finding-card img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: #000; flex-shrink: 0; }
.finding-card__body h3 { font-family: var(--font-display); font-size: 15px; margin: 0 0 4px; }
.finding-card__body p { font-size: 13.5px; color: var(--text-dim); margin: 0; line-height: 1.45; }
.finding-badge { font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; border-radius: 999px; display: inline-block; margin-bottom: 6px; }
.finding-badge--amber { background: rgba(245,185,66,0.18); color: var(--amber); }
.finding-badge--coral { background: rgba(255,122,112,0.18); color: var(--coral); }
.finding-badge--audio { background: rgba(179,157,255,0.18); color: var(--violet); }
.finding-badge--sage { background: rgba(143,217,168,0.18); color: var(--sage); }

/* Severity color-coding: left border + tinted badge per risk level */
.finding-card.finding-sev--high { border-left: 4px solid var(--coral); }
.finding-card.finding-sev--medium { border-left: 4px solid var(--amber); }
.finding-card.finding-sev--low { border-left: 4px solid var(--sage); }

.findings-legend {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  margin: -2px 0 2px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: lowercase;
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-dot--high { background: var(--coral); }
.legend-dot--medium { background: var(--amber); }
.legend-dot--low { background: var(--sage); }

.card--steps ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.7; color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .scan-button__ring { animation: none; }
}
