:root {
  --bg-deep: #070a11;
  --bg-base: #0b0f19;
  --bg-surface: #121827;
  --bg-elevated: #1a2236;
  --bg-card: rgba(18, 24, 39, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(0, 240, 168, 0.3);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #8492a6;
  
  --signal-teal: #00f0a8;
  --signal-teal-dim: rgba(0, 240, 168, 0.12);
  --signal-amber: #f59e0b;
  --signal-amber-dim: rgba(245, 158, 11, 0.12);
  --signal-cyan: #38bdf8;
  --signal-cyan-dim: rgba(56, 189, 248, 0.12);
  --signal-rose: #fb7185;
  --signal-rose-dim: rgba(251, 113, 133, 0.12);

  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, serif;

  --shell-max: 1040px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0%, #151f33 0%, var(--bg-base) 60%);
  background-attachment: fixed;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--signal-teal);
  color: var(--bg-deep);
  padding: 0.5rem 1rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
}

.shell {
  width: 100%;
  max-width: var(--shell-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Header & Nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(11, 15, 25, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 8px;
  height: 8px;
  background-color: var(--signal-teal);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--signal-teal);
  animation: pulse-dot 2.5s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 14px var(--signal-teal); }
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--border-subtle);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--signal-teal);
  border: 1px solid var(--border-accent);
  background: var(--signal-teal-dim);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
}

.lang-switch:hover {
  background: var(--signal-teal);
  color: var(--bg-deep);
}

/* Hero Section */
.hero {
  padding-top: 4rem;
  padding-bottom: 3.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--signal-cyan);
  background: var(--signal-cyan-dim);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: #ffffff;
  margin-bottom: 1.5rem;
}

.hero-lead {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 820px;
  margin-bottom: 2.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--signal-teal);
}

.stat-card:nth-child(2)::before {
  background: var(--signal-cyan);
}

.stat-card:nth-child(3)::before {
  background: var(--signal-amber);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.stat-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Sections */
.section {
  padding-top: 4rem;
  padding-bottom: 4rem;
  border-bottom: 1px solid var(--border-subtle);
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--signal-teal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: clamp(1.6rem, 3.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 1.25rem;
}

.section-lead {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 800px;
}

.prose p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* Threat Breakdown Grid */
.threat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.threat-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.threat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.threat-badge.hidden {
  background: var(--signal-teal-dim);
  color: var(--signal-teal);
  border: 1px solid rgba(0, 240, 168, 0.25);
}

.threat-badge.visible {
  background: var(--signal-amber-dim);
  color: var(--signal-amber);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.threat-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.threat-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Comparison Cards */
.comparison-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.comparison-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.comparison-card.new {
  border-color: var(--border-accent);
  background: linear-gradient(180deg, rgba(0, 240, 168, 0.04) 0%, var(--bg-surface) 100%);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.comparison-card.old .card-tag {
  background: var(--signal-rose-dim);
  color: var(--signal-rose);
}

.comparison-card.new .card-tag {
  background: var(--signal-teal-dim);
  color: var(--signal-teal);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.step-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.step-bullet {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--signal-teal);
  margin-top: 0.1rem;
}

.comparison-card.old .step-bullet {
  color: var(--signal-rose);
}

/* Interactive Sandbox / Oscilloscope */
.sandbox-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-choice {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-choice:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.btn-choice.active {
  background: var(--signal-teal);
  color: var(--bg-deep);
  border-color: var(--signal-teal);
}

.select-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.select-input:focus {
  border-color: var(--signal-teal);
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--signal-amber);
  border-color: var(--signal-amber);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--bg-deep);
}

.btn-simulate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--signal-cyan);
  color: var(--bg-deep);
  border: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  margin-top: 0.75rem;
}

.btn-simulate:hover {
  background: #7dd3fc;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

/* Oscilloscope Display */
.oscilloscope-box {
  background: #050811;
  border: 1px solid rgba(0, 240, 168, 0.2);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1.5rem;
  position: relative;
  overflow: hidden;
}

.oscilloscope-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.oscilloscope-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--signal-teal);
}

.canvas-container {
  width: 100%;
  height: 220px;
  position: relative;
}

canvas#pulseCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.oscilloscope-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-color.target { background-color: var(--signal-amber); }
.legend-color.background { background-color: var(--signal-cyan); }
.legend-color.inbound { border-bottom: 2px solid var(--signal-teal); }
.legend-color.outbound { border-top: 2px solid var(--signal-teal); }

/* Telemetry Readout */
.telemetry-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  align-items: center;
}

.telemetry-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.telemetry-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
}

.telemetry-verdict {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.telemetry-verdict.detected {
  background: var(--signal-teal-dim);
  color: var(--signal-teal);
  border: 1px solid rgba(0, 240, 168, 0.3);
}

.telemetry-verdict.ambiguous {
  background: var(--signal-amber-dim);
  color: var(--signal-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.telemetry-verdict.missed {
  background: var(--signal-rose-dim);
  color: var(--signal-rose);
  border: 1px solid rgba(251, 113, 133, 0.3);
}

.drift-warning {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--signal-amber);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

/* Benchmark Bar Chart */
.benchmarks-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-top: 2rem;
}

.benchmarks-header {
  margin-bottom: 1.5rem;
}

.benchmark-bars {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.benchmark-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.benchmark-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.benchmark-name {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.benchmark-name.highlight {
  color: var(--signal-teal);
}

.benchmark-pct {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.benchmark-track {
  width: 100%;
  height: 18px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.benchmark-fill {
  height: 100%;
  background: var(--border-strong);
  border-radius: var(--radius-sm);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.benchmark-fill.highlight {
  background: linear-gradient(90deg, #00f0a8 0%, #38bdf8 100%);
  box-shadow: 0 0 12px rgba(0, 240, 168, 0.4);
}

.benchmark-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Drift Grid */
.drift-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.drift-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}

.drift-card.danger {
  border-color: rgba(251, 113, 133, 0.3);
}

.drift-card-tabs {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.drift-card-pct {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--signal-amber);
}

.drift-card.danger .drift-card-pct {
  color: var(--signal-rose);
}

.drift-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Callout Box */
.callout-box {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.05) 0%, var(--bg-surface) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 2.5rem;
}

.callout-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--signal-cyan);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.callout-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* Footer */
.site-footer {
  background: var(--bg-deep);
  border-top: 1px solid var(--border-subtle);
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
  margin-top: auto;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--signal-teal);
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  line-height: 1.6;
}

/* Media Queries */
@media (max-width: 640px) {
  .site-header {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  .main-nav {
    display: none;
  }
  .hero {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }
  .section {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }
  .sandbox-card {
    padding: 1.25rem;
  }
  .canvas-container {
    height: 180px;
  }
  .telemetry-card {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}
