:root {
  color-scheme: dark;
  --bg: #08080a;
  --surface: rgba(17, 17, 20, 0.72);
  --surface-hover: rgba(24, 24, 29, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  --fg: #f1f1f4;
  --muted: #a0a0aa;
  --dim: #6b6b75;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html {
  background: var(--bg);
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image:
    radial-gradient(1000px 460px at 75% -60px, rgba(255, 255, 255, 0.04), transparent 70%),
    radial-gradient(800px 400px at 15% 100%, rgba(255, 255, 255, 0.025), transparent 70%);
}

body.is-leaving .main {
  opacity: 0;
  transform: translateY(-6px);
  filter: blur(3px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), filter 0.18s var(--ease);
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(8, 8, 10, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.65);
  animation: dotPulse 3s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav a {
  position: relative;
  font-size: 13.5px;
  color: var(--dim);
  text-decoration: none;
  padding: 3px 0;
  transition: color 0.22s var(--ease);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.32s var(--ease);
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--fg);
}

.nav a[aria-current="page"]::after,
.nav a:hover::after {
  transform: scaleX(1);
}

/* Main Layout */
.main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(40px, 7vh, 76px) 24px 72px;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease), filter 0.22s var(--ease);
}

.narrow {
  max-width: 680px;
}

/* Hero Split with 3D Viewport */
.hero-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 36px;
  align-items: center;
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 380px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.04), rgba(10, 10, 12, 0.9) 75%);
  overflow: hidden;
  cursor: grab;
  opacity: 0;
  transform: scale(0.96);
  animation: stageIn 0.9s var(--ease) 120ms forwards;
}

.stage-wrap:active {
  cursor: grabbing;
}

@keyframes stageIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#scene-3d {
  width: 100%;
  height: 100%;
  display: block;
}

.stage-caption {
  position: absolute;
  bottom: 12px;
  right: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
  user-select: none;
}

/* Staggered Reveal */
.main h1 {
  opacity: 0;
  transform: translateY(22px);
  filter: blur(6px);
  animation: maskUp 0.75s var(--ease) 60ms forwards;
}

.main .kicker,
.main .lead,
.main .prose p,
.main .list-item,
.main .panel,
.main .spec-row,
.main .kv-row {
  opacity: 0;
  transform: translateY(14px);
  filter: blur(4px);
  animation: maskUp 0.7s var(--ease) var(--stagger, 80ms) forwards;
}

.main .rule {
  transform: scaleX(0);
  transform-origin: left;
  animation: drawRule 0.8s var(--ease) var(--stagger, 140ms) forwards;
}

@keyframes maskUp {
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes drawRule {
  to {
    transform: scaleX(1);
  }
}

.kicker {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(32px, 5vw, 42px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--fg);
  margin-bottom: 18px;
}

h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  margin-bottom: 8px;
}

.lead {
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--muted);
  max-width: 56ch;
}

.lead + .lead {
  margin-top: 14px;
}

.prose {
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--muted);
  max-width: 62ch;
}

.rule {
  height: 1px;
  background: var(--border);
  margin: 36px 0;
}

/* Inline Links */
a.u {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.24);
  padding-bottom: 1px;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

a.u:hover {
  border-color: rgba(255, 255, 255, 0.85);
}

/* Index / Directory Rows */
.list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.list-item {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: padding-left 0.28s var(--ease), border-color 0.22s var(--ease);
}

.list-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.03);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
  z-index: -1;
}

.list-item:hover::before {
  transform: scaleX(1);
}

.list-item:hover {
  padding-left: 16px;
  border-bottom-color: var(--border-hover);
}

.list-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--fg);
  min-width: 165px;
}

.list-desc {
  font-size: 14.5px;
  color: var(--muted);
  flex: 1;
}

.list-arrow {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--dim);
  transition: transform 0.28s var(--ease), color 0.22s var(--ease);
}

.list-item:hover .list-arrow {
  transform: translate(4px, -3px);
  color: var(--fg);
}

/* Cards */
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  perspective: 900px;
}

.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform-style: preserve-3d;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.22s var(--ease);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.06), transparent 65%);
}

.panel:hover::before {
  opacity: 1;
}

.panel:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

.panel p {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.68;
}

.panel p + p {
  margin-top: 10px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tags span {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.22s var(--ease), border-color 0.22s var(--ease);
}

.panel:hover .tags span {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.14);
}

/* Editorial 2-Column Spec Rows (for Networking & Code) */
.spec-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.spec-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  padding: 30px 12px;
  margin: 0 -12px;
  border-radius: 10px;
  border-bottom: 1px solid var(--border);
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}

.spec-row:hover {
  background: rgba(255, 255, 255, 0.02);
  border-bottom-color: var(--border-hover);
}

.spec-left h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 6px;
}

.spec-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

.spec-right p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.72;
}

.spec-right p + p {
  margin-top: 12px;
}

/* Key-Value Table */
.kv {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.kv-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
  transition: border-color 0.22s var(--ease), padding-left 0.22s var(--ease);
}

.kv-row:hover {
  border-bottom-color: var(--border-hover);
  padding-left: 4px;
}

.kv-k {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--dim);
}

.kv-v {
  font-size: 14.5px;
  color: var(--muted);
}

/* Copy Button */
.copy-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
}

.copy-btn:hover {
  color: var(--fg);
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.05);
}

.copy-btn:active {
  transform: scale(0.96);
}

/* Footer */
.site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 24px 36px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

@media (max-width: 760px) {
  .hero-split {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .stage-wrap {
    max-height: 300px;
  }
  .spec-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 24px 8px;
  }
}

@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .list-item {
    flex-direction: column;
    gap: 4px;
  }
  .list-arrow {
    display: none;
  }
  .kv-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .main h1,
  .main .kicker,
  .main .lead,
  .main .prose p,
  .main .list-item,
  .main .panel,
  .main .kv-row {
    opacity: 1;
    transform: none;
    filter: none;
    animation: none;
  }
  .main .rule {
    transform: scaleX(1);
    animation: none;
  }
  .brand-dot {
    animation: none;
  }
  a, .panel, .list-item, .list-arrow, .copy-btn {
    transition: none;
  }
}
