:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e8eef6;
  --muted: #8b9bb4;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --touch: 44px;
  --pad-x: 1rem;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
  width: 100%;
  max-width: 100%;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  gap: 0.75rem;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
}

.logo span { color: var(--accent); }

.nav-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: var(--touch);
  height: var(--touch);
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav {
  display: none;
  flex-direction: column;
  gap: 0;
  font-size: 0.95rem;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  background: rgba(15, 20, 25, 0.98);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem var(--pad-x) 0.75rem;
  z-index: 60;
  box-sizing: border-box;
}

.nav.open { display: flex; }

.nav a {
  color: var(--muted);
  text-decoration: none;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  padding: 0 0.35rem;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

@media (min-width: 768px) {
  :root { --pad-x: 1.25rem; }

  .nav-toggle { display: none; }

  .nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem 1.1rem;
    position: static;
    background: transparent;
    border: none;
    padding: 0;
  }

  .nav a {
    min-height: auto;
    padding: 0.35rem 0;
  }

  .nav a:hover,
  .nav a.active {
    background: transparent;
  }
}

/* Main */
main {
  flex: 1;
  padding: 1.5rem 0 2.5rem;
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  main { padding: 2rem 0 3rem; }
}

.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.hero p {
  color: var(--muted);
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  max-width: 36rem;
  margin: 0 auto;
}

.disclaimer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  overflow-wrap: anywhere;
}

.disclaimer strong { color: var(--yellow); }

/* Detector card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .card { padding: 1.25rem; margin-bottom: 1.5rem; }
}

.card label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

textarea {
  width: 100%;
  min-height: 180px;
  max-width: 100%;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  /* 16px prevents iOS auto-zoom on focus */
  font-size: 16px;
  line-height: 1.55;
  padding: 0.9rem;
  outline: none;
}

@media (min-width: 640px) {
  textarea {
    min-height: 200px;
    font-size: 1rem;
    padding: 1rem;
  }
}

textarea:focus { border-color: var(--accent); }

.toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.char-count {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.25rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  min-height: var(--touch);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex: 1 1 auto;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  flex: 0 1 auto;
  min-width: 5.5rem;
}

.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

@media (min-width: 480px) {
  .toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .toolbar-actions { flex-wrap: nowrap; }

  .btn { flex: 0 0 auto; font-size: 0.95rem; }
}

/* Results */
.results { display: none; }
.results.visible { display: block; }

.score-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .score-row {
    grid-template-columns: 160px 1fr;
    align-items: center;
  }
}

.score-ring {
  width: 140px;
  height: 140px;
  margin: 0 auto;
  position: relative;
}

.score-ring svg { transform: rotate(-90deg); display: block; }

.score-ring .bg {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 10;
}

.score-ring .fg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s;
}

.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-center .num {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.score-center .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.verdict { text-align: center; }

@media (min-width: 640px) {
  .verdict { text-align: left; }
}

.verdict h2 {
  font-size: clamp(1.1rem, 3.5vw, 1.25rem);
  margin-bottom: 0.35rem;
  overflow-wrap: anywhere;
}

.verdict p { color: var(--muted); font-size: 0.95rem; }

.signals {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.65rem;
}

.signal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

@media (min-width: 480px) {
  .signal {
    flex-direction: row;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 0.75rem 1rem;
  }
}

.signal-name { font-size: 0.9rem; overflow-wrap: anywhere; }
.signal-desc { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; overflow-wrap: anywhere; }

.signal-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
}

.badge-low { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge-mid { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }
.badge-high { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Content pages */
.page-title {
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}

.page-lead {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.prose h2 {
  font-size: clamp(1.05rem, 3vw, 1.2rem);
  margin: 1.5rem 0 0.6rem;
  overflow-wrap: anywhere;
}

.prose p, .prose li {
  color: var(--muted);
  margin-bottom: 0.75rem;
  overflow-wrap: anywhere;
}

.prose ul { padding-left: 1.25rem; margin-bottom: 1rem; }
.prose strong { color: var(--text); }

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-item summary {
  padding: 0.9rem 1rem;
  min-height: var(--touch);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}

@media (min-width: 640px) {
  .faq-item summary { padding: 1rem 1.15rem; }
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: "+";
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 400;
  flex-shrink: 0;
}

.faq-item[open] summary::after { content: "−"; }

.faq-item .faq-body {
  padding: 0 1rem 1.1rem;
  color: var(--muted);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

@media (min-width: 640px) {
  .faq-item .faq-body { padding: 0 1.15rem 1.1rem; }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0 calc(1.25rem + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: flex-start;
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
}

.footer-links a {
  color: var(--muted);
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  padding: 0 0.5rem;
  -webkit-tap-highlight-color: transparent;
}

.footer-links a:hover { color: var(--text); }

@media (min-width: 640px) {
  .footer-links {
    gap: 0.5rem 1rem;
  }
  .footer-links a {
    min-height: auto;
    padding: 0;
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .score-ring .fg,
  .nav-toggle span { transition: none; }
}
