@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Playfair+Display:wght@400;600;700;900&family=Source+Sans+3:wght@300;400;500;600;700&display=swap');

:root {
  --bg-deep: #0a0e1a;
  --bg-surface: #111827;
  --bg-card: #1a2236;
  --bg-elevated: #1f2a42;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --cyan-glow: rgba(34, 211, 238, 0.15);
  --teal: #2dd4bf;
  --orange: #fb923c;
  --orange-dim: #c2410c;
  --red: #f87171;
  --red-dim: #991b1b;
  --green: #4ade80;
  --green-dim: #166534;
  --yellow: #fbbf24;
  --purple: #a78bfa;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --border: #2a3654;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html { scroll-behavior: smooth; scrollbar-color: var(--cyan-dim) var(--bg-deep); }
body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
}

::selection { background: var(--cyan); color: var(--bg-deep); }

/* === NAV === */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  transition: all 0.3s;
}
nav.scrolled { background: rgba(10, 14, 26, 0.95); }
nav .nav-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
nav .logo {
  font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem;
  color: var(--cyan); letter-spacing: 0.05em;
  text-decoration: none;
}
nav .logo span { color: var(--text-muted); font-weight: 400; }
nav ul { list-style: none; display: flex; gap: 0.25rem; align-items: center; }
nav .nav-sep { width: 1px; height: 20px; background: var(--border); margin: 0 0.3rem; }
nav a {
  color: var(--text-dim); text-decoration: none; font-size: 0.85rem;
  font-weight: 500; padding: 0.4rem 0.8rem; border-radius: 6px;
  transition: all 0.2s; font-family: var(--font-mono);
}
nav a:hover, nav a.active { color: var(--cyan); background: var(--cyan-glow); }

/* === HERO === */
#hero {
  position: relative; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#hero-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.4;
}
.hero-content {
  position: relative; z-index: 2; text-align: center;
  max-width: 900px; padding: 2rem;
}
.hero-tag {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--cyan);
  letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 1.5rem;
  opacity: 0; animation: fadeUp 0.8s 0.3s forwards;
}
.hero-title {
  font-family: var(--font-display); font-size: clamp(2.8rem, 6vw, 5.5rem);
  font-weight: 900; line-height: 1.1; margin-bottom: 1rem;
  opacity: 0; animation: fadeUp 0.8s 0.5s forwards;
}
.hero-title .accent { color: var(--cyan); }
.hero-sub {
  font-size: 1.25rem; color: var(--text-dim); max-width: 600px;
  margin: 0 auto 2.5rem; font-weight: 300;
  opacity: 0; animation: fadeUp 0.8s 0.7s forwards;
}
.hero-badges {
  display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;
  opacity: 0; animation: fadeUp 0.8s 0.9s forwards;
}
.badge {
  font-family: var(--font-mono); font-size: 0.75rem; padding: 0.4rem 1rem;
  border: 1px solid var(--border); border-radius: 100px; color: var(--text-dim);
}
.badge.active { border-color: var(--cyan-dim); color: var(--cyan); background: var(--cyan-glow); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === SECTIONS === */
section {
  max-width: 1200px; margin: 0 auto;
  padding: 3rem 2rem;
}
.section-tag {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--cyan);
  letter-spacing: 0.15em; text-transform: uppercase; margin-bottom: 0.75rem;
}
.section-title {
  font-family: var(--font-display); font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700; margin-bottom: 1rem; line-height: 1.2;
}
.section-desc {
  color: var(--text-dim); font-size: 1.1rem; max-width: 700px;
  margin-bottom: 2rem; font-weight: 300;
}

/* === PROBLEM SECTION === */
.problem-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}
.problem-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem;
  transition: all 0.3s;
}
.problem-card:hover { border-color: var(--red-dim); transform: translateY(-2px); }
.problem-card .icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin-bottom: 1rem;
  background: rgba(248, 113, 113, 0.1); color: var(--red);
}
.problem-card h3 { font-family: var(--font-mono); font-size: 1rem; margin-bottom: 0.5rem; }
.problem-card p { color: var(--text-dim); font-size: 0.95rem; }

/* === ALGORITHM CARDS === */
.algo-section {
  margin-bottom: 2.5rem;
  padding: 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}
.algo-section::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.algo-section.flood::before { background: linear-gradient(90deg, var(--red), var(--orange)); }
.algo-section.tree::before { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.algo-section.multi::before { background: linear-gradient(90deg, var(--green), var(--teal)); }
.algo-section.geo::before { background: linear-gradient(90deg, var(--purple), var(--cyan)); }
.algo-section.winner::before { background: linear-gradient(90deg, var(--cyan), var(--teal), var(--green)); }
.algo-section.winner { border-color: var(--cyan-dim); box-shadow: 0 0 60px var(--cyan-glow); }

.algo-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem;
}
.algo-number {
  font-family: var(--font-mono); font-size: 0.75rem;
  padding: 0.2rem 0.6rem; border-radius: 4px;
  background: var(--bg-elevated); color: var(--text-muted);
}
.algo-section.winner .algo-number { background: var(--cyan-dim); color: #fff; }
.algo-name {
  font-family: var(--font-display); font-size: 1.8rem; font-weight: 700;
}
.algo-subtitle {
  color: var(--text-dim); font-size: 1rem; margin-bottom: 2rem;
  max-width: 600px;
}

.algo-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem;
  align-items: start;
}
@media (max-width: 900px) { .algo-body { grid-template-columns: 1fr; } }

.algo-canvas-wrap {
  position: relative; border-radius: 12px; overflow: hidden;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  aspect-ratio: 4/3;
}
.algo-canvas { width: 100%; height: 100%; display: block; }
.canvas-label {
  position: absolute; bottom: 8px; right: 10px;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--text-muted); opacity: 0.6;
}
.algo-details h4 {
  font-family: var(--font-mono); font-size: 0.85rem;
  color: var(--cyan); margin-bottom: 0.5rem; margin-top: 1.5rem;
}
.algo-details h4:first-child { margin-top: 0; }
.algo-details p, .algo-details li {
  color: var(--text-dim); font-size: 0.95rem;
}
.algo-details ul { padding-left: 1.2rem; }
.algo-details li { margin-bottom: 0.3rem; }

.pro-con { display: flex; gap: 1.5rem; margin-top: 1rem; }
.pro, .con {
  flex: 1; padding: 1rem; border-radius: 8px; font-size: 0.85rem;
}
.pro {
  background: rgba(74, 222, 128, 0.06); border: 1px solid var(--green-dim);
}
.con {
  background: rgba(248, 113, 113, 0.06); border: 1px solid var(--red-dim);
}
.pro h5 { color: var(--green); font-family: var(--font-mono); font-size: 0.75rem; margin-bottom: 0.4rem; }
.con h5 { color: var(--red); font-family: var(--font-mono); font-size: 0.75rem; margin-bottom: 0.4rem; }
.pro li, .con li { color: var(--text-dim); font-size: 0.82rem; margin-bottom: 0.2rem; }

/* === MATH SECTION === */
#math .formula-cards-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.formula-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.5rem; margin-bottom: 0;
}
.formula-card h4 {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--cyan);
  margin-bottom: 1rem; letter-spacing: 0.1em;
}
.formula {
  font-family: var(--font-display); font-size: 1.2rem;
  color: var(--text); text-align: center; padding: 1rem 0;
  letter-spacing: 0.02em;
}
.formula .var { color: var(--cyan); font-style: italic; }
.formula .op { color: var(--text-muted); }
.formula-desc {
  color: var(--text-dim); font-size: 0.85rem; margin-top: 0.75rem;
  border-top: 1px solid var(--border); padding-top: 0.75rem;
}

/* === COMPARISON TABLE === */
.comparison-wrap { overflow-x: auto; margin: 2rem 0; }
.comparison-table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
  font-family: var(--font-mono);
}
.comparison-table th, .comparison-table td {
  padding: 0.75rem 1rem; text-align: center;
  border-bottom: 1px solid var(--border);
}
.comparison-table thead th {
  background: var(--bg-elevated); color: var(--text-dim);
  font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase;
  position: sticky; top: 0;
}
.comparison-table thead th:first-child { text-align: left; }
.comparison-table tbody td:first-child {
  text-align: left; font-weight: 600; color: var(--text);
}
.comparison-table .winner-row { background: rgba(34, 211, 238, 0.05); }
.comparison-table .winner-row td {
  color: var(--cyan); font-weight: 600;
  border-bottom-color: var(--cyan-dim);
}

/* === BAR CHART === */
.bar-chart {
  display: flex; align-items: flex-end; gap: 2rem;
  height: 300px; padding: 2rem 0;
  border-bottom: 2px solid var(--border);
  justify-content: center;
}
.bar-col {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  flex: 1; max-width: 140px;
}
.bar {
  width: 100%; border-radius: 6px 6px 0 0;
  transition: height 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative; min-height: 4px;
}
.bar-label {
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--text-dim); text-align: center; max-width: 100px;
  word-break: break-word;
}
.bar-value {
  position: absolute; top: -28px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700;
  white-space: nowrap;
}

/* === ARCHITECTURE === */
.arch-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem; margin-top: 1.5rem;
}
.arch-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem;
  transition: all 0.3s;
}
.arch-card:hover { border-color: var(--cyan-dim); transform: translateY(-2px); }
.arch-card .source {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.25rem;
}
.arch-card h4 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--text); }
.arch-card .arrow { color: var(--cyan); }
.arch-card p { color: var(--text-dim); font-size: 0.9rem; }

/* === METRICS === */
.metrics-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem; margin-top: 2rem;
}
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem; text-align: center;
}
.metric-value {
  font-family: var(--font-display); font-size: 3rem; font-weight: 900;
  color: var(--cyan); line-height: 1;
}
.metric-value .unit { font-size: 1.2rem; color: var(--text-muted); }
.metric-label {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-dim);
  margin-top: 0.5rem; letter-spacing: 0.05em;
}

/* === NETWORK FORMATION === */
.formation-section { max-width: 1400px; }
.formation-wrap {
  display: grid; grid-template-columns: 1fr 360px; gap: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden;
  position: relative;
}
.formation-wrap::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--teal), var(--green));
}
.formation-canvas-wrap {
  position: relative; aspect-ratio: 4/3; background: #070b14;
}
#canvas-formation { width: 100%; height: 100%; display: block; }
.formation-controls {
  padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem;
  border-left: 1px solid var(--border); background: var(--bg-card);
}
.formation-step-num {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--cyan);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.formation-step-title {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700;
  margin: 0.25rem 0 0.5rem; line-height: 1.3;
}
.formation-step-desc {
  color: var(--text-dim); font-size: 0.88rem; line-height: 1.6;
}
.formation-btns {
  display: flex; gap: 0.5rem;
}
.form-btn {
  font-family: var(--font-mono); font-size: 0.78rem;
  padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text-dim); transition: all 0.2s;
}
.form-btn:hover:not(:disabled) { border-color: var(--cyan-dim); color: var(--text); }
.form-btn:disabled { opacity: 0.3; cursor: default; }
.form-btn-primary {
  background: var(--cyan-dim); color: #fff; border-color: var(--cyan);
  flex: 1;
}
.form-btn-primary:hover:not(:disabled) { background: var(--cyan); color: var(--bg-deep); }
.formation-log {
  flex: 1; overflow-y: auto; font-family: var(--font-mono); font-size: 0.6rem;
  color: var(--text-muted); line-height: 1.7;
  border-top: 1px solid var(--border); padding-top: 0.75rem;
}
.formation-log .fl-entry { padding: 1px 0; border-bottom: 1px solid rgba(42,54,84,0.3); }
.formation-log .fl-time { color: var(--cyan-dim); margin-right: 4px; }
@media (max-width: 900px) {
  .formation-wrap { grid-template-columns: 1fr; }
  .formation-controls { border-left: none; border-top: 1px solid var(--border); }
}

/* === SCALE SCENARIOS === */
.scale-scenarios { max-width: 1400px; }
.scenario {
  margin-bottom: 2.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}
.scenario::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--teal));
}
.scenario-header {
  padding: 2rem 2.5rem 0.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.scenario-badge {
  font-family: var(--font-mono); font-size: 0.7rem;
  padding: 0.2rem 0.7rem; border-radius: 4px;
  background: var(--cyan-dim); color: #fff;
}
.scenario-name {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 700;
}
.scenario-desc {
  padding: 0 2.5rem 1.5rem;
  color: var(--text-dim); font-size: 0.95rem; max-width: 800px;
}
.scenario-canvas-wrap {
  position: relative; width: 100%;
  aspect-ratio: 16/9;
  background: #070b14;
  border-top: 1px solid var(--border);
}
.scenario-canvas { width: 100%; height: 100%; display: block; }
.scenario-legend {
  position: absolute; top: 12px; left: 14px;
  background: rgba(10,14,26,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--text-dim); line-height: 1.8;
  z-index: 5;
}
.scenario-legend .lg-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
.scenario-stats {
  position: absolute; bottom: 12px; left: 14px; right: 14px;
  display: flex; gap: 10px; flex-wrap: wrap; z-index: 5;
}
.scenario-stat {
  background: rgba(10,14,26,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 12px;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--text-dim);
}
.scenario-stat .sv { color: var(--cyan); font-weight: 600; font-size: 0.8rem; }
.node-panel {
  position: absolute; top: 12px; right: 14px;
  width: 220px;
  background: rgba(10,14,26,0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--text-dim); line-height: 1.7;
  z-index: 5; max-height: 90%; overflow-y: auto;
}
.node-panel h5 {
  color: var(--cyan); font-size: 0.75rem; margin-bottom: 4px;
  border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.np-log-entry {
  padding: 2px 0; font-size: 0.6rem; color: var(--text-muted);
  border-bottom: 1px solid rgba(42,54,84,0.3);
}
.np-log-entry .np-time { color: var(--cyan-dim); margin-right: 4px; }

/* === RESILIENCE & ADAPTIVE QoS === */
.resilience-section { max-width: 1400px; }
.resilience-wrap {
  display: grid; grid-template-columns: 1fr 300px; gap: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; position: relative;
}
.resilience-wrap::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green));
}
.resilience-canvas-wrap {
  position: relative; aspect-ratio: 5/4; background: #070b14; cursor: crosshair;
}
#canvas-resilience { width: 100%; height: 100%; display: block; }
.resilience-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-muted);
  opacity: 0.5; pointer-events: none;
}
.resilience-panel {
  padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem;
  border-left: 1px solid var(--border); background: var(--bg-card);
  overflow-y: auto;
}
.resilience-panel h5 {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--cyan);
  letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px;
  border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.nhs-cluster-list {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px;
}
.nhs-cluster-row {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.65rem;
  padding: 4px 8px; border-radius: 4px;
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.nhs-cluster-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.nhs-cluster-name { flex: 1; color: var(--text-dim); }
.nhs-cluster-val { font-weight: 600; min-width: 36px; text-align: right; }
.nhs-cluster-level { font-size: 0.55rem; min-width: 48px; text-align: right; font-weight: 600; }
.nhs-gauge { text-align: center; position: relative; }
#canvas-nhs { display: block; margin: 0 auto; }
.nhs-value {
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 900;
  color: var(--green); margin-top: -6px; line-height: 1;
}
.nhs-level {
  font-family: var(--font-mono); font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.15em;
}
.nhs-components {
  font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-dim);
  line-height: 1.8; margin-top: 4px;
}
.nhs-comp-row { display: flex; justify-content: space-between; }
.nhs-comp-bar { height: 3px; background: rgba(100,116,139,0.2); border-radius: 2px; margin: 1px 0 4px; }
.nhs-comp-fill { height: 100%; border-radius: 2px; transition: width 0.5s, background 0.5s; }
.qos-classes { font-family: var(--font-mono); font-size: 0.6rem; line-height: 1.4; }
.qos-row {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px;
  border-radius: 4px; margin-bottom: 2px; transition: all 0.3s;
}
.qos-row.blocked { opacity: 0.25; text-decoration: line-through; }
.qos-row.allowed { opacity: 1; }
.qos-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.qos-label { flex: 1; color: var(--text-dim); }
.qos-status { font-weight: 600; font-size: 0.55rem; }
.failure-presets { display: flex; flex-wrap: wrap; gap: 4px; }
.failure-presets h5 { width: 100%; }
.fail-btn {
  font-family: var(--font-mono); font-size: 0.6rem;
  padding: 3px 6px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text-dim); transition: all 0.2s;
}
.fail-btn:hover { border-color: var(--red-dim); color: var(--red); background: rgba(248,113,113,0.06); }
#fail-reset { border-color: var(--green-dim); color: var(--green); }
#fail-reset:hover { background: rgba(74,222,128,0.06); }
.resilience-log {
  flex: 1; min-height: 40px; max-height: 100px; overflow-y: auto;
  font-family: var(--font-mono); font-size: 0.55rem; color: var(--text-muted);
  line-height: 1.5; border-top: 1px solid var(--border); padding-top: 4px;
}
.res-log-entry { padding: 1px 0; border-bottom: 1px solid rgba(42,54,84,0.2); }
@media (max-width: 900px) {
  .resilience-wrap { grid-template-columns: 1fr; }
  .resilience-panel { border-left: none; border-top: 1px solid var(--border); max-height: none; }
}

/* === CONCLUSION === */
.conclusion-summary {
  display: flex; align-items: center; gap: 2rem;
  margin-bottom: 3rem;
}
.concl-problem, .concl-solution {
  flex: 1; padding: 2rem; border-radius: 12px;
}
.concl-problem {
  background: rgba(248,113,113,0.04); border: 1px solid var(--red-dim);
}
.concl-solution {
  background: rgba(34,211,238,0.04); border: 1px solid var(--cyan-dim);
}
.concl-problem h4 { color: var(--red); font-family: var(--font-mono); font-size: 0.85rem; margin-bottom: 0.5rem; }
.concl-solution h4 { color: var(--cyan); font-family: var(--font-mono); font-size: 0.85rem; margin-bottom: 0.5rem; }
.concl-problem p, .concl-solution p { color: var(--text-dim); font-size: 0.95rem; }
.concl-arrow {
  font-size: 2rem; color: var(--text-muted); flex-shrink: 0;
}
.concl-results { margin-bottom: 3rem; }
.concl-results-title {
  font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-dim);
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 1.5rem;
}
.concl-results-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}
.concl-result {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem; text-align: center;
}
.concl-result-value {
  font-family: var(--font-display); font-size: 2.5rem; font-weight: 900; line-height: 1;
}
.concl-result-label {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-dim);
  margin-top: 0.4rem; letter-spacing: 0.05em;
}
.concl-result-desc {
  font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem;
}
.concl-innovations { margin-bottom: 3rem; }
.concl-innov-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
}
.concl-innov {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem;
  transition: all 0.3s;
}
.concl-innov:hover { border-color: var(--cyan-dim); transform: translateY(-2px); }
.concl-innov-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.concl-innov h4 { font-size: 1rem; margin-bottom: 0.4rem; }
.concl-innov p { color: var(--text-dim); font-size: 0.88rem; }
.concl-roadmap { margin-bottom: 3rem; }
.concl-timeline { position: relative; padding-left: 2rem; }
.concl-timeline::before {
  content: ''; position: absolute; left: 7px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.concl-phase {
  position: relative; margin-bottom: 2rem;
}
.concl-phase-marker {
  position: absolute; left: -2rem; top: 4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg-elevated); border: 2px solid var(--text-muted);
}
.concl-phase.done .concl-phase-marker {
  background: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}
.concl-phase-content h4 {
  font-family: var(--font-mono); font-size: 0.9rem; margin-bottom: 0.3rem;
}
.concl-phase.done .concl-phase-content h4 { color: var(--cyan); }
.concl-phase-content p { color: var(--text-dim); font-size: 0.9rem; }
.concl-cta {
  background: var(--bg-surface); border: 1px solid var(--cyan-dim);
  border-radius: 16px; padding: 3rem; text-align: center;
  box-shadow: 0 0 40px var(--cyan-glow);
}
.concl-cta h3 {
  font-family: var(--font-display); font-size: 1.8rem; font-weight: 700;
  margin-bottom: 1rem;
}
.concl-cta p { color: var(--text-dim); font-size: 1.05rem; max-width: 600px; margin: 0 auto 1.5rem; }
.concl-cta-links { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
.concl-cta-item {
  font-family: var(--font-mono); font-size: 0.85rem; color: var(--cyan);
  padding: 0.5rem 1.2rem; border: 1px solid var(--cyan-dim);
  border-radius: 8px; transition: all 0.2s;
}
.concl-cta-item:hover { background: var(--cyan-glow); }
@media (max-width: 768px) {
  .conclusion-summary { flex-direction: column; }
  .concl-arrow { transform: rotate(90deg); }
}

/* === TL;DR === */
#tldr { padding-top: 1rem; padding-bottom: 1rem; }
.tldr-card {
  background: var(--bg-card);
  border: 1px solid var(--cyan-dim);
  border-radius: 16px;
  padding: 2.5rem;
  position: relative;
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.08), inset 0 0 30px rgba(34, 211, 238, 0.02);
}
.tldr-card::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(135deg, var(--cyan-dim), transparent 40%, transparent 60%, var(--teal));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.tldr-text {
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.8;
  margin-bottom: 2rem;
  max-width: 800px;
}
.tldr-text strong { color: var(--cyan); font-weight: 600; }
.tldr-stats {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  justify-content: center;
}
.tldr-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 100px;
}
.tldr-num {
  font-family: var(--font-display);
  font-size: 1.8rem; font-weight: 900;
  color: var(--cyan); line-height: 1;
}
.tldr-label {
  font-family: var(--font-mono);
  font-size: 0.7rem; color: var(--text-muted);
  margin-top: 0.3rem; letter-spacing: 0.05em;
}

/* === GLOSSARY === */
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.glossary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  transition: all 0.3s;
}
.glossary-card:hover { border-color: var(--cyan-dim); transform: translateY(-2px); }
.glossary-card dt {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 0.35rem;
}
.glossary-card dd {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}
@media (max-width: 900px) {
  .glossary-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .glossary-grid { grid-template-columns: 1fr; }
  .tldr-stats { gap: 0.75rem; }
  .tldr-stat { min-width: 80px; padding: 0.5rem 1rem; }
  .tldr-num { font-size: 1.4rem; }
}

/* === FOOTER === */
footer {
  border-top: 1px solid var(--border);
  padding: 3rem 2rem; text-align: center;
  color: var(--text-muted); font-size: 0.85rem;
}

/* === ANIMATIONS === */
.reveal {
  opacity: 0; transform: translateY(30px);
  transition: opacity 0.6s, transform 0.6s;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* === RESPONSIVE === */

/* Hamburger menu toggle */
.nav-toggle {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 1.4rem; padding: 0.3rem;
}

@media (max-width: 960px) {
  .nav-toggle { display: block; }
  nav ul {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    background: rgba(10,14,26,0.97); backdrop-filter: blur(20px);
    flex-direction: column; padding: 1rem; gap: 0.25rem;
    border-bottom: 1px solid var(--border);
  }
  nav ul.open { display: flex; }
  nav a { padding: 0.6rem 1rem; display: block; }
}

@media (max-width: 768px) {
  section { padding: 2rem 1rem; }
  .hero-title { font-size: 2.2rem !important; }
  .hero-sub { font-size: 1rem; }
  .algo-section { padding: 1.25rem; }
  .algo-body { grid-template-columns: 1fr; }
  .algo-canvas-wrap { aspect-ratio: 3/2; }
  .pro-con { flex-direction: column; }
  .bar-chart { gap: 0.5rem; height: 200px; }
  .bar-label { font-size: 0.6rem; }
  .section-title { font-size: 1.6rem !important; }
  .formula { font-size: 1rem; }
  #math .formula-cards-grid { grid-template-columns: 1fr; }
  .comparison-table { font-size: 0.7rem; }
  .comparison-table th, .comparison-table td { padding: 0.4rem 0.5rem; }
  .arch-grid { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .metric-value { font-size: 2rem; }

  /* Formation */
  .formation-wrap { grid-template-columns: 1fr; }
  .formation-controls { border-left: none; border-top: 1px solid var(--border); }
  .formation-canvas-wrap { aspect-ratio: 4/3; }

  /* Scenarios */
  .scenario-canvas-wrap { aspect-ratio: 4/3; }
  .scenario-legend { font-size: 0.55rem; padding: 6px 8px; }
  .node-panel { width: 160px; font-size: 0.55rem; }
  .scenario-stats { flex-wrap: wrap; }
  .scenario-stat { font-size: 0.55rem; padding: 4px 8px; }

  /* Resilience */
  .resilience-wrap { grid-template-columns: 1fr; }
  .resilience-panel { border-left: none; border-top: 1px solid var(--border); max-height: none; }
  .resilience-canvas-wrap { aspect-ratio: 4/3; }

  /* Conclusion */
  .conclusion-summary { flex-direction: column; }
  .concl-arrow { transform: rotate(90deg); }
  .concl-results-grid { grid-template-columns: repeat(2, 1fr); }
  .concl-result-value { font-size: 1.8rem; }
  .concl-innov-grid { grid-template-columns: 1fr; }

  /* TL;DR */
  .tldr-stats { gap: 0.5rem; }
  .tldr-stat { min-width: 70px; padding: 0.5rem 0.75rem; }
  .tldr-num { font-size: 1.3rem; }

  /* Glossary */
  .glossary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  section { padding: 2.5rem 0.75rem; }
  .hero-title { font-size: 1.8rem !important; }
  .hero-badges { gap: 0.5rem; }
  .badge { font-size: 0.65rem; padding: 0.3rem 0.7rem; }
  .problem-grid { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: 1fr; }
  .concl-results-grid { grid-template-columns: 1fr; }
  .bar-chart { height: 160px; gap: 0.3rem; }
  .tldr-stats { flex-direction: column; align-items: center; }
  .sim-charts-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   APPROACH DIVIDERS & BADGES
   ============================================================ */

.approach-divider {
  text-align: center;
  margin: 2.5rem 0 1.5rem;
  position: relative;
}

.approach-divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border);
}

.divider-label {
  position: relative;
  display: inline-block;
  padding: 0.4rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  border-radius: 20px;
}

.sota-label {
  background: var(--bg-surface);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.proposal-label {
  background: var(--bg-surface);
  color: var(--cyan);
  border: 1px solid var(--cyan-dim);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.1);
}

.sota-badge {
  background: rgba(251, 191, 36, 0.15) !important;
  color: var(--yellow) !important;
  border: 1px solid rgba(251, 191, 36, 0.3) !important;
}

.proposal-badge {
  background: rgba(34, 211, 238, 0.15) !important;
  color: var(--cyan) !important;
  border: 1px solid var(--cyan-dim) !important;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.15);
}

/* SOTA side-by-side grid */
.sota-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem;
}
.sota-grid .algo-section { margin-bottom: 0; padding: 1.5rem; }
.sota-grid .algo-body { grid-template-columns: 1fr; gap: 1.5rem; }
.sota-grid .algo-canvas-wrap { aspect-ratio: 4/3; }
.sota-grid .algo-name { font-size: 1.2rem; }
.sota-grid .algo-subtitle { font-size: 0.82rem; margin-bottom: 1rem; }
.sota-grid .algo-details h4 { font-size: 0.78rem; margin-top: 1rem; }
.sota-grid .algo-details p, .sota-grid .algo-details li { font-size: 0.85rem; }
.sota-grid .pro-con { flex-direction: column; gap: 0.75rem; }
@media (max-width: 1100px) { .sota-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) { .sota-grid { grid-template-columns: 1fr; } }

/* Visual distinction: SOTA sections have subtle warm tint, proposal has cyan glow */
.algo-section.managed,
.algo-section.nexthop {
  border-left: 2px solid rgba(251, 191, 36, 0.2);
}

.algo-section.winner {
  border-left: 2px solid var(--cyan-dim);
  background: rgba(34, 211, 238, 0.02);
}

/* ============================================================
   HOP COST SECTION
   ============================================================ */

.hop-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 2rem 0;
}

.hop-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  border: 1px solid var(--border);
}

.hop-card h4 {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.hop-formula {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.hop-card p {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.hop-flooding {
  border-color: var(--red-dim);
  background: rgba(248, 113, 113, 0.03);
}

.hop-system5 {
  border-color: var(--cyan-dim);
  background: rgba(34, 211, 238, 0.03);
}

.hop-example {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hop-step {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--border);
}

.hop-step strong {
  color: var(--red);
}

.hop-step.hop-wall {
  border-left: 2px solid var(--red);
  background: rgba(248, 113, 113, 0.08);
  color: var(--red);
}

.hop-step.hop-s5 {
  border-left: 2px solid var(--cyan-dim);
}

.hop-step.hop-s5 strong {
  color: var(--cyan);
}

@media (max-width: 768px) {
  .hop-comparison {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   SIMULATION RESULTS SECTION
   ============================================================ */

.sim-results-section {
  padding-bottom: 2rem;
}

/* Summary table */
.sim-table-wrap {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}

.sim-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.sim-table th {
  background: var(--bg-elevated);
  color: var(--cyan);
  padding: 0.75rem 1rem;
  text-align: right;
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.sim-table th:first-child {
  text-align: left;
}

.sim-table td {
  padding: 0.6rem 1rem;
  text-align: right;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(42, 54, 84, 0.5);
}

.sim-table td:first-child {
  text-align: left;
  color: var(--text);
  font-weight: 500;
}

.sim-table tr:hover td {
  background: rgba(34, 211, 238, 0.03);
}

.sim-table .flood-val {
  color: var(--red);
}

.sim-table .sys5-val {
  color: var(--cyan);
}

.sim-table .stress-row td {
  background: rgba(248, 113, 113, 0.03);
}

.sim-table .stress-row td:first-child {
  border-left: 2px solid var(--orange);
}

/* Charts grid */
.sim-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

.sim-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.sim-chart-card h4 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.scale-toggle-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--cyan);
  background: transparent;
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  margin-left: 0.75rem;
  transition: background 0.2s;
  vertical-align: middle;
}

.scale-toggle-btn:hover {
  background: var(--cyan-glow);
}

.sim-chart-wrap {
  width: 100%;
  height: 280px;
  position: relative;
}

.sim-chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 768px) {
  .sim-charts-grid {
    grid-template-columns: 1fr;
  }
  .sim-chart-wrap {
    height: 240px;
  }
}
