:root {
  --bg: #0a0e14;
  --bg-card: #131920;
  --bg-elevated: #1a2030;
  --border: #1e2a3a;
  --text: #e0e0e0;
  --text-dim: #8899aa;
  --accent: #00ff88;
  --accent-dim: rgba(0, 255, 136, 0.15);
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: rgba(10, 14, 20, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  font-family: var(--mono); font-weight: 700; font-size: 1.2rem;
  color: var(--text); display: flex; align-items: center; gap: 6px;
}
.nav-logo:hover { text-decoration: none; }
.accent { color: var(--accent); }
.nav-links { display: flex; gap: 20px; }
.nav-link {
  color: var(--text-dim); font-size: 0.88rem; font-weight: 500;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--accent); text-decoration: none; }
.nav-hamburger {
  display: none; background: none; border: 1px solid var(--border);
  color: var(--text); font-size: 1.3rem; padding: 4px 10px;
  border-radius: var(--radius-sm); cursor: pointer;
}
.nav-hamburger:hover { border-color: var(--accent); color: var(--accent); }

/* Views */
.view { display: none; }
.view.active { display: block; }

/* Terminal Hero */
.terminal-window {
  max-width: 750px; margin: 40px auto 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.terminal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: rgba(0,0,0,0.3); border-bottom: 1px solid var(--border);
}
.terminal-dots { display: flex; gap: 7px; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }
.terminal-title { font-family: var(--mono); font-size: 0.78rem; color: var(--text-dim); }
.terminal-body { padding: 36px 32px; text-align: center; }
.hero-title {
  font-family: var(--mono); font-size: 3rem; font-weight: 800;
  text-shadow: 0 0 40px rgba(0,255,136,0.3), 0 0 80px rgba(0,255,136,0.1);
  margin-bottom: 8px;
}
.hero-subtitle {
  font-size: 1.1rem; color: var(--text-dim); font-weight: 500; margin-bottom: 12px;
}
.hero-desc { font-size: 0.95rem; color: var(--text-dim); max-width: 520px; margin: 0 auto; }

/* Controls Bar */
.controls-bar { max-width: 1200px; margin: 32px auto 0; padding: 0 24px; }
.category-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.tab {
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); font-size: 0.85rem;
  font-family: var(--font); font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.search-wrap { max-width: 400px; }
.search-input {
  width: 100%; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); font-size: 0.95rem; font-family: var(--font);
  outline: none; transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }

/* Protocol Grid */
.protocol-grid {
  max-width: 1200px; margin: 24px auto 60px; padding: 0 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px;
}
.protocol-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
}
.protocol-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--card-accent, var(--accent));
}
.protocol-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  border-color: var(--card-accent, var(--accent));
}
.card-body { padding: 20px; }
.card-icon { font-size: 2rem; margin-bottom: 8px; }
.card-name {
  font-family: var(--mono); font-weight: 700; font-size: 1.1rem; margin-bottom: 4px;
}
.card-desc { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 12px; line-height: 1.5; }
.card-footer { display: flex; justify-content: space-between; align-items: center; }
.card-badge {
  font-size: 0.72rem; padding: 3px 10px; border-radius: 12px;
  background: var(--accent-dim); color: var(--accent); font-weight: 600;
}
.card-cta {
  font-size: 0.85rem; color: var(--card-accent, var(--accent)); font-weight: 600;
}

/* Protocol Detail */
.back-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 18px; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font); font-size: 0.9rem; margin: 24px 24px 0;
  transition: all 0.2s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }
.protocol-detail { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
.protocol-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
  padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.proto-icon { font-size: 2.5rem; }
.proto-title { font-family: var(--mono); font-size: 1.8rem; font-weight: 800; }
.proto-fullname { font-size: 0.95rem; color: var(--text-dim); }
.proto-about { font-size: 0.92rem; color: var(--text-dim); line-height: 1.7; margin-top: 8px; max-width: 700px; }
.protocol-content { display: flex; gap: 24px; }
.protocol-main { flex: 1; min-width: 0; }

/* Animation Container */
.animation-container {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; position: relative;
  min-height: 380px;
}
.anim-svg { width: 100%; height: 380px; display: block; }
.anim-controls {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-top: 12px; flex-wrap: wrap;
}
.ctrl-btn {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 1rem; display: flex; align-items: center;
  justify-content: center; transition: all 0.2s;
}
.ctrl-btn:hover { border-color: var(--accent); color: var(--accent); }
.speed-control { display: flex; gap: 4px; margin-left: 8px; }
.speed-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 4px 10px; border-radius: 12px; font-size: 0.78rem;
  font-family: var(--mono); cursor: pointer; transition: all 0.2s;
}
.speed-btn:hover { border-color: var(--accent); color: var(--accent); }
.speed-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.step-indicator {
  display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap;
}
.step-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border); transition: background 0.3s; cursor: pointer;
}
.step-dot.active { background: var(--accent); }
.step-dot.done { background: var(--text-dim); }

/* Info Panel */
.info-panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-top: 12px;
}
#info-title { font-family: var(--mono); font-size: 1rem; margin-bottom: 8px; color: var(--accent); }
#info-text { font-size: 0.9rem; color: var(--text-dim); line-height: 1.7; }

/* Key Facts */
.key-facts {
  width: 280px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; align-self: flex-start;
  position: sticky; top: 80px;
}
.kf-title {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700;
  margin-bottom: 16px; color: var(--accent);
}
.kf-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
}
.kf-row:last-child { border-bottom: none; }
.kf-label { color: var(--text-dim); font-weight: 500; }
.kf-value { color: var(--text); font-weight: 600; text-align: right; max-width: 55%; }
.kf-security {
  padding: 2px 8px; border-radius: 8px; font-size: 0.75rem; font-weight: 700;
}
.kf-security.secure { background: rgba(0,255,136,0.15); color: #00ff88; }
.kf-security.insecure { background: rgba(255,71,87,0.15); color: #ff4757; }
.kf-security.depends { background: rgba(255,217,61,0.15); color: #ffd93d; }
.security-notes {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
.security-notes h4 {
  font-size: 0.82rem; color: #ff4757; font-family: var(--mono);
  margin-bottom: 6px;
}
.security-notes p { font-size: 0.8rem; color: var(--text-dim); line-height: 1.6; }

/* Footer */
.footer {
  text-align: center; padding: 24px; font-size: 0.85rem;
  color: var(--text-dim); border-top: 1px solid var(--border);
}

/* Mobile Nav */
.nav-links.open {
  display: flex !important; flex-direction: column;
  position: absolute; top: 56px; left: 0; right: 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 16px 24px; gap: 12px;
}

/* Animation SVG styles */
.anim-endpoint-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 4,4; }
.anim-endpoint-label {
  fill: var(--text-dim); font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 600; text-anchor: middle;
}
.anim-endpoint-icon { font-size: 28px; text-anchor: middle; }
.anim-arrow { stroke-width: 2.5; fill: none; marker-end: url(#arrowhead); }
.anim-arrow-label {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  font-weight: 700; text-anchor: middle;
}
.anim-arrow-sublabel {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  fill: var(--text-dim); text-anchor: middle;
}
.anim-packet {
  rx: 4; ry: 4;
}

@media (max-width: 900px) {
  .protocol-content { flex-direction: column; }
  .key-facts { width: 100%; position: static; }
}
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-hamburger { display: block; }
  .hero-title { font-size: 2rem; }
  .terminal-body { padding: 24px 16px; }
  .protocol-grid { grid-template-columns: 1fr; padding: 0 16px; }
  .controls-bar { padding: 0 16px; }
  .category-tabs { gap: 6px; }
  .tab { padding: 5px 12px; font-size: 0.8rem; }
  .protocol-detail { padding: 16px 16px 40px; }
  .anim-svg { height: 320px; }
  .proto-title { font-size: 1.3rem; }
}
