:root {
  --bg: #050810;
  --surface: #080d18;
  --surface2: #0d1424;
  --border: #1a2540;
  --border-bright: #243558;
  --accent: #00e5ff;
  --accent-dim: #00e5ff22;
  --text: #c8d8f0;
  --text-dim: #4a6080;
  --text-muted: #2a3a55;
  --green: #00ff88;
  --yellow: #ffd600;
  --orange: #ff8c00;
  --red: #ff3c6e;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-display: 'Bebas Neue', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

/* Desktop: no scroll. Mobile: scrollable */
@media (min-width: 768px) {
  html, body { overflow: hidden; }
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--text-muted) 1px, transparent 1px),
    linear-gradient(90deg, var(--text-muted) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

/* ── App Shell ── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 14px;
  gap: 10px;
}

@media (max-width: 767px) {
  .app {
    height: auto;
    min-height: 100vh;
    padding: 10px;
    gap: 8px;
  }
}

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 0 4px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.shield svg {
  width: 32px; height: 32px;
  filter: drop-shadow(0 0 6px var(--accent));
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.05em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 20px var(--accent);
}

.brand .sub {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.topbar-right { display: flex; gap: 16px; }

/* Hide badges on small screens */
@media (max-width: 767px) {
  .topbar-right { display: none; }
  .brand h1 { font-size: 26px; }
}

.badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 9px; color: var(--text-dim);
  letter-spacing: 0.1em; text-transform: uppercase;
}

.dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 5px var(--green);
  animation: pulse 2s infinite;
}
.dot.amber { background: var(--orange); box-shadow: 0 0 5px var(--orange); }

/* ── Main Layout ── */
.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

/* Stack columns on mobile */
@media (max-width: 767px) {
  .main {
    grid-template-columns: 1fr;
    flex: none;
    gap: 8px;
  }
}

/* ── Left Column ── */
.left-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

@media (max-width: 767px) {
  .left-col { min-height: 280px; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.panel-title {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.dots { display: flex; gap: 4px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; }
.dots span:nth-child(1) { background: #ff5f57; }
.dots span:nth-child(2) { background: #febc2e; }
.dots span:nth-child(3) { background: #28c840; }

.panel-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

textarea#emailInput {
  flex: 1;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  min-height: 0;
}

@media (max-width: 767px) {
  textarea#emailInput {
    min-height: 180px;
    font-size: 13px;
  }
}

textarea#emailInput::placeholder { color: var(--text-muted); }
textarea#emailInput:focus { border-color: var(--accent); }

.analyze-btn {
  margin-top: 10px;
  width: 100%;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color 0.2s;
  flex-shrink: 0;
}
.analyze-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 0;
}
.analyze-btn:hover::before { transform: translateX(0); }
.analyze-btn:hover { color: var(--bg); }
.analyze-btn span { position: relative; z-index: 1; }
.analyze-btn:disabled { border-color: var(--border-bright); color: var(--text-dim); cursor: not-allowed; }
.analyze-btn:disabled::before { display: none; }

@media (max-width: 767px) {
  .analyze-btn { padding: 14px; font-size: 12px; }
}

.scan-bar {
  display: none; height: 2px;
  background: var(--border);
  margin-top: 6px; overflow: hidden; flex-shrink: 0;
}
.scan-bar.active { display: block; }
.scan-bar::after {
  content: ''; display: block; height: 100%; width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 1.1s ease-in-out infinite;
}

/* ── Right Column ── */
.right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

@media (max-width: 767px) {
  .right-col { gap: 8px; }
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 2px;
  color: var(--text-muted);
  gap: 10px;
  min-height: 120px;
}
.empty-state .big-icon { font-size: 32px; opacity: 0.3; }
.empty-state p { font-size: 11px; letter-spacing: 0.1em; }

/* Results panel */
.results-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.results-panel::-webkit-scrollbar { width: 3px; }
.results-panel::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

/* Verdict card */
.verdict-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.verdict-main {
  padding: 14px 18px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
}
.verdict-text .vtag {
  font-size: 8px; letter-spacing: 0.2em;
  color: var(--text-dim); text-transform: uppercase; margin-bottom: 4px;
}
.verdict-text .vlabel {
  font-family: var(--font-display);
  font-size: 36px; letter-spacing: 0.04em; line-height: 1;
}
.verdict-text .vsummary {
  font-size: 11px; color: var(--text-dim); margin-top: 4px;
}

@media (max-width: 767px) {
  .verdict-text .vlabel { font-size: 28px; }
  .verdict-main { padding: 12px 14px; }
}

.score-ring { width: 70px; height: 70px; position: relative; flex-shrink: 0; }
.score-ring svg { transform: rotate(-90deg); width: 70px; height: 70px; }
.score-ring .track { fill: none; stroke: var(--border); stroke-width: 5; }
.score-ring .fill {
  fill: none; stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 188; stroke-dashoffset: 188;
  transition: stroke-dashoffset 1s cubic-bezier(0.4,0,0.2,1);
}
.score-num-wrap {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-num-wrap .snum { font-family: var(--font-display); font-size: 22px; line-height: 1; }
.score-num-wrap .slabel { font-size: 7px; color: var(--text-dim); letter-spacing: 0.08em; }

.det-bar {
  padding: 7px 18px; display: flex; gap: 16px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.det-item { display: flex; align-items: center; gap: 5px; font-size: 9px; color: var(--text-dim); letter-spacing: 0.06em; }
.det-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 3px var(--accent); }

/* Color variants */
.c-green .vlabel { color: var(--green); text-shadow: 0 0 15px var(--green); }
.c-green .verdict-main { background: rgba(0,255,136,0.03); }
.c-green .fill { stroke: var(--green); }
.c-green .snum { color: var(--green); }

.c-yellow .vlabel { color: var(--yellow); text-shadow: 0 0 15px var(--yellow); }
.c-yellow .verdict-main { background: rgba(255,214,0,0.03); }
.c-yellow .fill { stroke: var(--yellow); }
.c-yellow .snum { color: var(--yellow); }

.c-orange .vlabel { color: var(--orange); text-shadow: 0 0 15px var(--orange); }
.c-orange .verdict-main { background: rgba(255,140,0,0.03); }
.c-orange .fill { stroke: var(--orange); }
.c-orange .snum { color: var(--orange); }

.c-red .vlabel { color: var(--red); text-shadow: 0 0 15px var(--red); }
.c-red .verdict-main { background: rgba(255,60,110,0.04); }
.c-red .fill { stroke: var(--red); }
.c-red .snum { color: var(--red); }

/* Signals */
.signals-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden; flex-shrink: 0;
}
.signal-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text); line-height: 1.5;
  transition: background 0.1s;
}
.signal-row:last-child { border-bottom: none; }
.signal-row:hover { background: var(--surface2); }
.sig-icon { flex-shrink: 0; width: 16px; text-align: center; font-size: 12px; }
.sig-tag {
  flex-shrink: 0; font-size: 8px; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 1px 5px;
  border-radius: 2px; margin-top: 2px; border: 1px solid;
}
.t-rule { background: rgba(0,229,255,0.07); color: var(--accent); border-color: rgba(0,229,255,0.2); }
.t-ml   { background: rgba(138,43,226,0.08); color: #b06eff; border-color: rgba(138,43,226,0.2); }
.t-ai   { background: rgba(0,255,136,0.07); color: var(--green); border-color: rgba(0,255,136,0.2); }

/* ── Chat Panel ── */
.chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

@media (max-width: 767px) {
  .chat-panel { min-height: 300px; }
}

.ai-model-tag {
  font-size: 9px; padding: 2px 6px;
  background: rgba(0,100,200,0.12);
  border: 1px solid #1a3a60;
  color: #4a7ab5; border-radius: 2px; letter-spacing: 0.08em;
}

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 0;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

.msg { display: flex; gap: 8px; animation: fadeUp 0.2s ease both; }
.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 24px; height: 24px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0; margin-top: 2px;
}
.msg.ai .msg-avatar { background: rgba(0,229,255,0.1); border: 1px solid rgba(0,229,255,0.2); color: var(--accent); }
.msg.user .msg-avatar { background: rgba(100,100,150,0.15); border: 1px solid var(--border); color: var(--text-dim); }

.msg-bubble {
  max-width: 85%; padding: 8px 11px; border-radius: 2px;
  font-size: 11.5px; line-height: 1.7;
}
.msg.ai .msg-bubble { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.msg.user .msg-bubble { background: rgba(0,229,255,0.07); border: 1px solid rgba(0,229,255,0.15); color: var(--text); }

.msg-label { font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 4px; }
.msg.ai .msg-label { color: var(--accent); }
.msg.user .msg-label { color: var(--text-dim); text-align: right; }

.typing-dots span {
  display: inline-block; width: 4px; height: 4px;
  border-radius: 50%; background: var(--text-dim); margin: 0 1px;
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.chat-hint {
  font-size: 9px; color: var(--text-muted);
  padding: 0 12px 6px; letter-spacing: 0.06em; flex-shrink: 0;
}

.chat-input-row {
  display: flex; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.chat-input {
  flex: 1; background: transparent;
  border: 1px solid var(--border); border-radius: 2px;
  padding: 8px 10px; color: var(--text);
  font-family: var(--font-mono); font-size: 11.5px;
  outline: none; transition: border-color 0.2s;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:focus { border-color: var(--accent); }
.chat-input:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 767px) {
  .chat-input { font-size: 13px; padding: 10px; }
}

.chat-send {
  padding: 8px 14px; background: transparent;
  border: 1px solid var(--border); color: var(--text-dim);
  font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; border-radius: 2px; transition: all 0.2s; flex-shrink: 0;
}
.chat-send:hover { border-color: var(--accent); color: var(--accent); }
.chat-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Footer ── */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

@media (max-width: 767px) {
  .footer {
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    text-align: center;
  }
}

.footer-copy {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.footer-center {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-sep {
  color: var(--text-muted);
  font-size: 10px;
}

.footer-privacy {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-privacy:hover { color: var(--accent); }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@keyframes scan {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.3); }
}