:root {
  --bg: #0e0b14;
  --bg-2: #120e1c;
  --paper: #161222;
  --paper-2: #1c1730;
  --ink: #e8e4f0;
  --muted: #9990ad;
  --dim: #655e78;
  --accent: #c4a8ff;
  --accent-strong: #d4bcff;
  --accent-dim: #a07ee0;
  --accent-surface: rgba(196, 168, 255, 0.08);
  --accent-glow: rgba(196, 168, 255, 0.10);
  --line: #2a2440;
  --line-accent: #3d3558;
  --surface: #1e1830;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  --mono: 'JetBrains Mono', monospace;
  --serif: 'Instrument Serif', serif;
  --sans: 'DM Sans', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding: 1.5rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

.bg-orb {
  position: fixed;
  z-index: -1;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
}

.orb-a {
  width: 350px;
  height: 350px;
  background: rgba(196, 168, 255, 0.06);
  top: -100px;
  left: -80px;
  border-radius: 50%;
}

.orb-b {
  width: 400px;
  height: 400px;
  background: rgba(160, 126, 224, 0.04);
  right: -140px;
  bottom: -120px;
  border-radius: 50%;
}

/* ── Header ── */
.site-header {
  margin: 0 auto;
  max-width: 1160px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.brand h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(2rem, 4.8vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.eyebrow {
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ── Top Nav ── */
.top-nav {
  margin: 1.2rem auto 1rem;
  max-width: 1160px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}

.nav-link {
  display: block;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  padding: 0.75rem 0.8rem;
  font: 500 0.85rem/1.2 var(--sans);
  transition: all 200ms ease;
}

.nav-link:hover {
  transform: translateY(-1px);
  border-color: var(--line-accent);
  color: var(--ink);
  background: var(--paper-2);
  box-shadow: var(--shadow);
}

.nav-link.is-active {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-surface);
  box-shadow: 0 4px 20px rgba(196, 168, 255, 0.08);
}

/* ── Layout ── */
.layout {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1rem;
}

.layout.layout-single {
  grid-template-columns: minmax(0, 1fr);
}

/* ── Side Nav ── */
.side-nav {
  position: sticky;
  top: 1rem;
  align-self: start;
  padding: 1rem;
  border-radius: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: fadeUp 350ms ease both;
}

.side-nav-title {
  margin: 0 0 0.7rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.side-nav a {
  display: block;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.3rem 0;
  transition: color 150ms;
}

.side-nav a:hover {
  color: var(--ink);
}

/* ── Cards ── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  margin-bottom: 0.85rem;
  animation: fadeUp 340ms ease both;
  transition: background 200ms;
}

.card:hover {
  background: var(--paper-2);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 0.6rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5rem;
}

.card h3 {
  margin-bottom: 0.45rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
}

.card p {
  margin: 0.45rem 0 0.55rem;
  color: var(--muted);
}

/* ── Callout ── */
.callout {
  border-left: 3px solid var(--accent-dim);
  background: var(--accent-surface);
  padding: 0.55rem 0.9rem;
  border-radius: 0 8px 8px 0;
}

.callout p {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Code ── */
code,
pre {
  font-family: var(--mono);
}

code {
  font-size: 0.82rem;
  background: var(--surface);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--accent);
}

pre {
  margin: 0.5rem 0 0.7rem;
  padding: 0.8rem 1rem;
  background: rgba(10, 7, 18, 0.6);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.65;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.4rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--dim);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

td {
  color: var(--muted);
}

td code {
  font-size: 0.78rem;
}

/* ── Lists ── */
ul,
ol {
  margin: 0.55rem 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.dense li {
  margin-bottom: 0.28rem;
}

/* ── Misc ── */
.note {
  color: var(--dim);
  font-size: 0.85rem;
  font-style: italic;
}

a {
  color: var(--accent);
  transition: color 150ms;
}

a:hover {
  color: var(--accent-strong);
}

/* ── Section Grid (home) ── */
.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.section-card {
  text-decoration: none;
  color: inherit;
  transition: all 200ms;
}

.section-card:hover {
  border-color: var(--line-accent);
  transform: translateY(-2px);
}

.section-card h3 {
  margin-top: 0;
  color: var(--accent);
}

.section-card p {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Animations ── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive ── */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
  }
}

@media (max-width: 720px) {
  body {
    padding: 1rem;
  }

  .site-header {
    flex-direction: column;
    align-items: start;
  }

  .top-nav {
    grid-template-columns: 1fr;
  }

  .section-grid {
    grid-template-columns: 1fr;
  }
}
