:root {
  --bg: #070a12;
  --bg2: #070a12;
  --surface: rgba(255, 255, 255, 0.06);
  --surface2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --faint: rgba(255, 255, 255, 0.45);
  --brand: #23f0c7;
  --brand2: #7c5cff;
  --warn: #ffcc00;
  --ok: #39d98a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius2: 22px;
  --max: 1100px;
}

html[data-theme="light"] {
  --bg: #f6fff8;
  --bg2: #f6fff8;
  --surface: rgba(0, 0, 0, 0.04);
  --surface2: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.10);
  --text: rgba(0, 0, 0, 0.88);
  --muted: rgba(0, 0, 0, 0.62);
  --faint: rgba(0, 0, 0, 0.45);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg2));
}

/* Ensure background stays single (no overlay layers). */
body::before,
body::after {
  content: none;
}

html[data-theme="light"] body {
  background: linear-gradient(180deg, var(--bg), var(--bg2));
}

a { color: inherit; }
a:hover { color: var(--brand); }

/* Motion primitives (kept subtle + disabled via prefers-reduced-motion). */
@keyframes lhFloat {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(0.5deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

@keyframes lhShimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.skip-link {
  position: absolute;
  left: 12px;
  top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  transform: translateY(-140%);
  transition: transform 180ms ease;
  z-index: 60;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 2px solid rgba(35, 240, 199, 0.60);
  outline-offset: 2px;
}

.nav a:focus-visible,
.btn:focus-visible,
.paper-nav button:focus-visible {
  outline: 2px solid rgba(35, 240, 199, 0.70);
  outline-offset: 2px;
}

.container {
  width: min(var(--max), calc(100% - 48px));
  margin: 0 auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(12px);
  background: rgba(7, 10, 18, 0.55);
}

html[data-theme="light"] .site-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(246, 247, 251, 0.70);
}

.site-header-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.25), transparent 45%),
    linear-gradient(135deg, rgba(35, 240, 199, 1), rgba(124, 92, 255, 1));
  box-shadow: 0 10px 30px rgba(35, 240, 199, 0.18);
  transform-origin: 50% 60%;
  animation: lhFloat 6.5s ease-in-out infinite;
}

.brand-name {
  font-weight: 760;
  letter-spacing: 0.2px;
}

.brand-tagline {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 650;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.nav a:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  transform: translateY(-1px);
}

.nav a[aria-current="page"] {
  color: var(--text);
  background: rgba(35, 240, 199, 0.10);
  border-color: rgba(35, 240, 199, 0.25);
}

.btn.nav-toggle {
  display: none;
  min-width: 44px;
  padding: 10px 12px;
}

/* Theme toggle */
.theme-toggle {
  min-width: 44px;
  padding: 10px 12px;
}

/* Sections */
.page {
  padding: 28px 0 70px;
}

.hero {
  padding: 54px 0 18px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 18px;
  align-items: stretch;
}

.hero h1, .hero h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.6px;
}

.hero p {
  color: var(--muted);
  margin: 12px 0 0;
  font-size: 16px;
}

.kicker {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.accent {
  background: linear-gradient(90deg, var(--brand), rgba(35, 240, 199, 0.75), rgba(124, 92, 255, 0.9));
  background-size: 220% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: lhShimmer 7s linear infinite;
}

.accent-static {
  animation: none;
  background-position: 0% 50%;
}

.accent-sweep {
  animation: lhShimmer 16s linear infinite reverse;
}

.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-inner {
  padding: 18px 18px;
}

.hero-aside {
  position: relative;
}

.hero-aside::before {
  content: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
}

.metric .label {
  color: var(--muted);
  font-weight: 650;
  font-size: 12px;
}

.metric .value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 780;
  letter-spacing: -0.2px;
}

.metric .hint {
  margin-top: 2px;
  color: var(--faint);
  font-size: 12px;
}

.section {
  padding: 18px 0;
}

.section h3 {
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: -0.2px;
}

.section p {
  color: var(--muted);
  margin: 10px 0 0;
}

.lede {
  color: var(--muted);
  font-size: 16px;
  margin: 10px 0 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
}

.badge {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 650;
  font-size: 12px;
}

.badge strong {
  color: var(--text);
  font-weight: 800;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(35, 240, 199, 0.28);
  background: var(--surface2);
}

.list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.list-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 10px 22px rgba(35, 240, 199, 0.22);
  transform: translateY(2px);
}

.cta {
  border: 1px solid rgba(35, 240, 199, 0.22);
  background: linear-gradient(180deg, rgba(35, 240, 199, 0.08), rgba(124, 92, 255, 0.06));
}

.cta-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 750;
  position: relative;
  isolation: isolate;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

html[data-theme="light"] .btn {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.btn::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 999px;
  background:
    radial-gradient(160px 110px at 15% 10%, rgba(35, 240, 199, 0.28), transparent 60%),
    radial-gradient(160px 110px at 85% 90%, rgba(124, 92, 255, 0.24), transparent 60%);
  filter: blur(14px);
  opacity: 0;
  z-index: -1;
  transition: opacity 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(240, 243, 242, 0.35);
  background: var(--surface2);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

.btn:hover::after {
  opacity: 1;
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  border-color: rgba(223, 13, 13, 0.55);
  background:
    radial-gradient(140px 90px at 20% 20%, rgba(35, 240, 199, 0.40), transparent 60%),
    radial-gradient(140px 90px at 85% 85%, rgba(124, 92, 255, 0.34), transparent 60%),
    linear-gradient(135deg, rgba(35, 240, 199, 0.22), rgba(124, 92, 255, 0.18));
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(35, 240, 199, 0.12) inset;
}

html[data-theme="light"] .btn.primary {
  border-color: rgba(35, 240, 199, 0.45);
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.10),
    0 0 0 1px rgba(35, 240, 199, 0.10) inset;
}

/* Logs */
.log-box {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  height: 180px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  position: relative;
}

.network-canvas {
  width: 100%;
  height: 680px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.network-canvas canvas {
  border-radius: var(--radius);
}

.log-track {
  position: absolute;
  inset: 0;
  will-change: transform;
  animation: scrollLogs 14s linear infinite;
}

.log-box:hover .log-track { animation-play-state: paused; }

.log-track div {
  padding: 7px 12px;
  color: rgba(255, 255, 255, 0.86);
}

html[data-theme="light"] .log-track div {
  color: rgba(0, 0, 0, 0.78);
}

@keyframes scrollLogs {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* Reveal */
[data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 600ms ease, transform 600ms ease;
  transition-delay: var(--reveal-delay, 0ms);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
footer {
  padding: 26px 0 0;
  color: var(--faint);
  text-align: center;
}

.site-footer {
  margin-top: 36px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 14px;
  text-align: left;
}

.footer-title {
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--text);
  margin-bottom: 8px;
}

.footer-text {
  color: var(--muted);
  margin: 0;
}

.footer-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 0;
}

.footer-link:hover {
  color: var(--text);
}

.footer-mini {
  margin-top: 12px;
  color: var(--faint);
  font-size: 12px;
}

/* Research papers */
.paper-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.paper-nav button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.paper-nav button:hover {
  transform: translateY(-1px);
  border-color: rgba(35, 240, 199, 0.35);
  background: var(--surface2);
}

.paper {
  display: none;
  margin-top: 14px;
}

.paper.active { display: block; }

.paper h1 {
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: -0.2px;
}

.paper h2 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.paper .meta {
  color: var(--faint);
  font-size: 13px;
}

.paper .abstract {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

/* Small tweaks */
@media (max-width: 980px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 980px) {
  .site-header-inner {
    flex-wrap: wrap;
  }

  .btn.nav-toggle {
    display: inline-flex;
  }

  .nav {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    padding-top: 10px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: max-height 240ms ease, opacity 240ms ease, transform 240ms ease;
  }

  .site-header[data-nav-open="true"] .nav {
    max-height: 420px;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav a {
    padding: 10px 12px;
  }

  .hero-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .container { width: min(var(--max), calc(100% - 28px)); }
  .site-header-inner { padding: 12px 0; }
  .hero { padding: 36px 0 14px; }
  .panel-inner { padding: 16px 14px; }
  .metrics { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .network-canvas { height: 520px; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { transition: none; }
  .brand-mark,
  .accent,
  .log-track {
    animation: none !important;
  }
}
