:root {
  --bg: #f3f6fb;
  --bg-soft: #e9eef7;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-soft: #f6f8fc;
  --text: #1f2937;
  --muted: #556070;
  --border: #d6deea;
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --nav: #111827;
  --nav-border: rgba(255,255,255,0.06);
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.10);
  --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.06);
  --radius: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --max: 1180px;
  --content: 760px;
}

body.dark-mode {
  --bg: #0f172a;
  --bg-soft: #0b1220;
  --surface: #1e293b;
  --surface-strong: #1e293b;
  --surface-soft: #0f172a;
  --text: #e5edf7;
  --muted: #97a6bb;
  --border: #334155;
  --accent: #60a5fa;
  --accent-2: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --nav: #0b1120;
  --nav-border: rgba(255,255,255,0.05);
  --shadow: 0 14px 36px rgba(0,0,0,0.28);
  --shadow-soft: 0 8px 20px rgba(0,0,0,0.20);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59,130,246,0.10), transparent 28%),
    radial-gradient(circle at top right, rgba(99,102,241,0.08), transparent 26%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 240px);
  color: var(--text);
  line-height: 1.65;
  scroll-behavior: smooth;
  transition: background-color .25s ease, color .25s ease;
}

body {
  overflow-x: hidden;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--nav);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
}

.topbar-inner {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
  display: block;
  box-shadow: 0 3px 10px rgba(0,0,0,0.20);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-label {
  white-space: nowrap;
}

.nav-desktop {
  margin-left: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: .35rem;
  list-style: none;
  flex-wrap: wrap;
}

.nav-links a {
  color: #fff;
  text-decoration: none;
  padding: .7rem .9rem;
  border-radius: 12px;
  font-size: .96rem;
  transition: .2s ease;
  opacity: .95;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  background: rgba(255,255,255,0.08);
}

.nav-links a.nav-cve {
  background: linear-gradient(135deg, #ef4444, #f59e0b);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.22);
}

.nav-links a.nav-cve:hover,
.nav-links a.nav-cve[aria-current="page"] {
  background: linear-gradient(135deg, #dc2626, #ea580c);
  color: #fff;
  opacity: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: .5rem;
}

.toggle-btn,
.menu-btn {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-radius: 12px;
  padding: .7rem 1rem;
  cursor: pointer;
  transition: .2s ease;
  font: inherit;
}

.toggle-btn:hover,
.menu-btn:hover {
  background: rgba(255,255,255,0.14);
}

.menu-btn {
  display: none;
}

.nav-shell {
  display: none;
}

.nav-shell.open {
  display: none;
}

.nav-shell .nav-links a.nav-cve {
  color: #fff;
}

main {
  flex: 1;
}

.hero {
  padding: 4.5rem 0 3rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .8rem;
  border-radius: 999px;
  background: rgba(59,130,246,0.10);
  color: var(--accent);
  font-size: .88rem;
  font-weight: 700;
  border: 1px solid rgba(59,130,246,0.14);
  margin-bottom: 1rem;
}

.page-title,
.hero h1,
.article-title {
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -.05em;
  margin-bottom: 1rem;
  text-wrap: balance;
}

.lead {
  color: var(--muted);
  max-width: 64ch;
  font-size: clamp(1rem, 1.35vw, 1.08rem);
  text-wrap: pretty;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.18fr .82fr;
  gap: 2rem;
  align-items: center;
}

.hero-actions,
.actions,
.cta {
  display: flex;
  gap: .8rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn,
.cta-link,
.show-more-btn,
.submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: .9rem 1.25rem;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 600;
  transition: .2s ease;
  border: 1px solid transparent;
  font: inherit;
}

.btn-primary,
.cta-link,
.submit-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(59,130,246,0.22);
}

.btn-secondary,
.show-more-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn:hover,
.cta-link:hover,
.show-more-btn:hover,
.submit-btn:hover {
  transform: translateY(-1px);
}

.card,
.panel,
.search-panel,
.stat,
.article-shell,
.toc-shell,
.cta-box,
.hero-card,
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section {
  padding: 1rem 0 4rem;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: -.04em;
  text-wrap: balance;
}

.section-text,
.section-subtitle,
.muted,
.article-description,
p,
li {
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.meta,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  color: var(--muted);
  font-size: .84rem;
}

.badge,
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .35rem .65rem;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge.beginner,
.badge-green {
  color: var(--success);
  background: rgba(16,185,129,0.10);
  border: 1px solid rgba(16,185,129,0.14);
}

.badge.intermediate,
.badge-blue {
  color: var(--warning);
  background: rgba(245,158,11,0.10);
  border: 1px solid rgba(245,158,11,0.14);
}

.badge.advanced {
  color: var(--danger);
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.14);
}

.tag {
  color: var(--accent);
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.12);
}

footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  color: var(--muted);
  font-size: .92rem;
  margin-top: auto;
  background: var(--surface-soft);
}

body.dark-mode footer {
  background: var(--surface-soft);
}

.footer-inner {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 14px;
  padding: .95rem 1rem;
  font: inherit;
  transition: .2s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(59,130,246,0.45);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.10);
}

textarea {
  resize: vertical;
}

.callout {
  padding: 1rem 1.1rem;
  border-radius: 18px;
  margin: 1.2rem 0;
  border: 1px solid transparent;
}

.callout.info {
  background: rgba(59,130,246,0.08);
  border-color: rgba(59,130,246,0.12);
}

.callout.warn {
  background: rgba(245,158,11,0.10);
  border-color: rgba(245,158,11,0.14);
}

.callout.success {
  background: rgba(16,185,129,0.10);
  border-color: rgba(16,185,129,0.14);
}

.code-block,
.command-line {
  position: relative;
  border-radius: 18px;
  padding: 1.15rem;
  overflow-x: auto;
  margin: 1.2rem 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88rem;
  line-height: 1.65;
  white-space: pre;
}

.code-block {
  background: #111827;
  color: #e5edf7;
  border: 1px solid #374151;
}

.command-line {
  background: #0b1220;
  color: #34d399;
  border: 1px solid rgba(52,211,153,0.16);
}

.code-block::before {
  content: attr(data-lang);
  position: absolute;
  top: .6rem;
  right: .9rem;
  color: #94a3b8;
  font-size: .75rem;
  text-transform: uppercase;
}

.copy-btn {
  position: absolute;
  top: .55rem;
  left: .75rem;
  padding: .25rem .5rem;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,0.18);
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  cursor: pointer;
  font-size: .72rem;
}

@media (max-width: 1080px) {
  .hero-grid,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .nav-desktop {
    display: none;
  }

  .menu-btn {
    display: inline-flex;
  }

  .nav-shell {
    position: fixed;
    inset: 72px 1rem auto 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: .75rem;
  }

  .nav-shell.open {
    display: block;
  }

  .nav-shell .nav-links {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-shell .nav-links a {
    color: var(--text);
  }
}

@media (max-width: 720px) {
  .page-title,
  .hero h1,
  .article-title {
    max-width: 100%;
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .lead {
    max-width: 100%;
  }

  .hero {
    padding: 3rem 0 2rem;
  }

  .topbar-inner {
    min-height: 66px;
  }

  .brand-label {
    display: none;
  }

  .actions,
  .cta,
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn,
  .cta-link,
  .show-more-btn,
  .submit-btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .code-block,
  .command-line {
    font-size: .8rem;
  }
}