/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0b0c0f;
  --bg2:      #13141a;
  --bg3:      #1b1d26;
  --border:   rgba(255,255,255,0.08);
  --border2:  rgba(255,255,255,0.14);
  --text:     #f0f0ee;
  --muted:    #7a7d8a;
  --accent:   #e8ff47;
  --red:      #ff4545;
  --orange:   #ff9f2e;
  --green:    #3ddc84;
  --red-bg:   rgba(255,69,69,0.08);
  --orange-bg:rgba(255,159,46,0.08);
  --green-bg: rgba(61,220,132,0.08);
  --font-head: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --radius:   12px;
  --radius-lg:18px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-head);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== ALERT OVERLAY ===== */
.alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn .25s ease;
}
.alert-overlay.active { display: flex; }

.alert-box {
  background: #1a0808;
  border: 1.5px solid var(--red);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  animation: alertPop .35s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 0 60px rgba(255,69,69,0.3);
}

.alert-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  animation: pulse 0.6s ease infinite alternate;
}

.alert-hey {
  font-family: var(--font-head);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--red);
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  animation: shake 0.4s ease 0.1s;
}

.alert-msg {
  font-size: 1rem;
  color: #ffb3b3;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}
.alert-msg strong { color: var(--red); }

.alert-close {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: opacity .15s, transform .1s;
}
.alert-close:hover { opacity: 0.85; }
.alert-close:active { transform: scale(0.97); }

/* ===== PAGE LAYOUT ===== */
.page {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ===== HEADER ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 3rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.logo-icon { font-size: 1.3rem; }
.logo-ai { color: var(--accent); }

.header-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  border: 0.5px solid var(--border2);
  border-radius: 20px;
  padding: 4px 12px;
}

/* ===== HERO ===== */
.hero { margin-bottom: 2.5rem; }

.hero-title {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}
.hero-accent { color: var(--accent); }

.hero-sub {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 400;
}

/* ===== SCAN SECTION ===== */
.scan-section { margin-bottom: 2rem; }

.input-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.input-wrap { position: relative; margin-bottom: 1rem; }

.input-area {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-head);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 1rem 1.1rem;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
}
.input-area:focus { border-color: var(--accent); }
.input-area::placeholder { color: var(--muted); }

.char-count {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 6px;
}

.btn-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #0b0c0f;
  border: none;
  border-radius: var(--radius);
  padding: 13px 28px;
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: opacity .15s, transform .1s;
}
.btn-scan:hover { opacity: 0.88; }
.btn-scan:active { transform: scale(0.97); }
.btn-scan:disabled { opacity: 0.4; cursor: default; }

.btn-icon { font-size: 1.1rem; transition: transform .2s; }
.btn-scan:not(:disabled):hover .btn-icon { transform: translateX(4px); }

.btn-clear {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 13px 20px;
  font-family: var(--font-head);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-clear:hover { color: var(--text); border-color: var(--border2); }

/* ===== LOADING ===== */
.loading-state {
  text-align: center;
  padding: 3rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-bars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 5px;
  height: 32px;
  margin-bottom: 1rem;
}
.loading-bars span {
  display: block;
  width: 5px;
  background: var(--accent);
  border-radius: 3px;
  animation: barBounce 0.9s ease-in-out infinite;
}
.loading-bars span:nth-child(1){ height: 14px; animation-delay: 0s; }
.loading-bars span:nth-child(2){ height: 22px; animation-delay: .1s; }
.loading-bars span:nth-child(3){ height: 30px; animation-delay: .2s; }
.loading-bars span:nth-child(4){ height: 22px; animation-delay: .3s; }
.loading-bars span:nth-child(5){ height: 14px; animation-delay: .4s; }

/* ===== ERROR ===== */
.error-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--red-bg);
  border: 1px solid rgba(255,69,69,0.25);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--red);
  font-size: 0.9rem;
}
.error-icon {
  width: 28px;
  height: 28px;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== RESULT CARD ===== */
.result-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 3rem;
  animation: fadeUp .4s ease;
}

/* Risk banner */
.risk-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
}
.risk-left { display: flex; align-items: center; gap: 14px; }

.risk-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.risk-level {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.risk-caption {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.risk-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 5px 14px;
  border-radius: 20px;
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.metric-card {
  background: var(--bg3);
  padding: 1.1rem 1.25rem;
}
.metric-card:not(:last-child) { border-right: 1px solid var(--border); }
.metric-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.metric-val {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.metric-unit { font-size: 1rem; font-weight: 400; color: var(--muted); }

/* Bar */
.bar-section { padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); }
.bar-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.bar-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.bar-pct {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}
.bar-track {
  background: var(--bg3);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 20px;
  width: 0%;
  transition: width .8s cubic-bezier(.4,0,.2,1);
}

/* Signals */
.signals-section { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.section-heading {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.reason-list { display: flex; flex-direction: column; gap: 8px; }
.reason-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: #d0d0cc;
}
.reason-item::before {
  content: "!";
  width: 20px;
  height: 20px;
  background: rgba(255,69,69,0.15);
  color: var(--red);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* AI section */
.ai-section { padding: 1.25rem 1.5rem; }
.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.ai-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.ai-model-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  background: rgba(232,255,71,0.08);
  border: 1px solid rgba(232,255,71,0.2);
  border-radius: 20px;
  padding: 2px 10px;
  letter-spacing: 0.04em;
}
.ai-body {
  font-size: 0.9rem;
  color: #c0c0bc;
  line-height: 1.7;
  white-space: pre-wrap;
  font-family: var(--font-head);
}

/* ===== RISK COLOURS ===== */
.risk-high .risk-banner  { background: rgba(255,69,69,0.06); }
.risk-high .risk-dot     { background: var(--red); color: var(--red); }
.risk-high .risk-level   { color: var(--red); }
.risk-high .risk-badge   { background: rgba(255,69,69,0.12); color: var(--red); }
.risk-high .bar-fill     { background: var(--red); }
.risk-high .bar-pct      { color: var(--red); }

.risk-medium .risk-banner { background: rgba(255,159,46,0.06); }
.risk-medium .risk-dot    { background: var(--orange); color: var(--orange); }
.risk-medium .risk-level  { color: var(--orange); }
.risk-medium .risk-badge  { background: rgba(255,159,46,0.12); color: var(--orange); }
.risk-medium .bar-fill    { background: var(--orange); }
.risk-medium .bar-pct     { color: var(--orange); }

.risk-low .risk-banner  { background: rgba(61,220,132,0.06); }
.risk-low .risk-dot     { background: var(--green); color: var(--green); }
.risk-low .risk-level   { color: var(--green); }
.risk-low .risk-badge   { background: rgba(61,220,132,0.12); color: var(--green); }
.risk-low .bar-fill     { background: var(--green); }
.risk-low .bar-pct      { color: var(--green); }

/* ===== FOOTER ===== */
.site-footer {
  text-align: center;
  padding: 2rem 0 3rem;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 0.5px solid var(--border);
  font-family: var(--font-mono);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: none } }
@keyframes alertPop { from { opacity: 0; transform: scale(.88) } to { opacity: 1; transform: scale(1) } }
@keyframes shake {
  0%,100% { transform: translateX(0) }
  20%      { transform: translateX(-8px) }
  40%      { transform: translateX(8px) }
  60%      { transform: translateX(-5px) }
  80%      { transform: translateX(5px) }
}
@keyframes pulse { from { opacity: 1 } to { opacity: .55 } }
@keyframes barBounce {
  0%,100% { transform: scaleY(0.6) }
  50%     { transform: scaleY(1) }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .hero-title { font-size: 2rem; }
  .metrics-grid { grid-template-columns: repeat(3,1fr); }
  .metric-val { font-size: 1.5rem; }
}