@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f0f2f8;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --accent: #6366f1;
  --accent-soft: #eef2ff;
  --accent-mid: #a5b4fc; 
  --accent-dark: #4338ca;

  --green: #10b981;
  --green-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --blue: #3b82f6;
  --blue-soft: #eff6ff;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);

  --mono: 'JetBrains Mono', monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.doc-wrap {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 0 32px;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.search-bar {
  padding: 0 16px 16px;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
  transition: 0.2s;
}

.search-bar input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-bar input::placeholder { color: var(--text-muted); }

.nav-section {
  padding: 4px 0;
  border-top: 1px solid var(--border-light);
}

.nav-section:first-of-type { border-top: none; }

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 16px 16px 6px;
}

.nav-link {
  display: block;
  padding: 6px 16px 6px 18px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: 0.18s;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.nav-link.active {
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

/* ── Content ── */

.content {
  padding: 48px 56px 80px;
  max-width: 1100px;
}

/* ── Page show/hide ── */

.page { display: none; }
.page.active { display: block; }

/* ── Typography ── */

h1 {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

h2 {
  font-size: 26px;
  font-weight: 700;
  margin-top: 52px;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

h3 {
  font-size: 19px;
  font-weight: 600;
  margin-top: 34px;
  margin-bottom: 10px;
}

p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Badges ── */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  line-height: 1.3;
}

.badge-async {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge-cpu {
  background: var(--green-soft);
  color: #047857;
}

.badge-gpu {
  background: var(--blue-soft);
  color: #1d4ed8;
}

/* ── Table of Contents ── */

.toc {
  background: var(--accent-soft);
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 28px;
}

.toc strong {
  font-size: 13px;
  color: var(--accent-dark);
  display: block;
  margin-bottom: 8px;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li { margin: 4px 0; }

.toc li a {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  transition: 0.15s;
}

.toc li a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* ── Pipeline Flow ── */

.pipeline-flow {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.pf-step {
  text-align: center;
  flex: 1;
  min-width: 90px;
  padding: 8px 6px;
}

.pf-num {
  width: 32px;
  height: 32px;
  margin: 0 auto 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pf-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pf-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.pf-arrow {
  font-size: 20px;
  color: var(--accent-mid);
  flex-shrink: 0;
  padding: 0 4px;
}

/* ── Key Numbers / Param Cards ── */

.param-card {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 12px;
  box-shadow: var(--shadow-sm);
  transition: 0.2s;
}

.param-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent-mid);
}

.param-card div:first-child {
  font-size: 22px !important;
  font-weight: 700 !important;
  color: var(--accent) !important;
}

.param-card div:last-child {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  margin-top: 4px;
}

/* ── Callout / Warning ── */

.callout {
  background: var(--accent-soft);
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 24px 0;
}

.callout p {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.warn-box {
  background: var(--amber-soft);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 24px 0;
}

.warn-box p {
  margin: 0;
  font-size: 14px;
  color: #92400e;
}

/* ── Inline Code ── */

code {
  font-family: var(--mono);
  background: var(--surface-soft);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: .86em;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--accent-dark);
}

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

/* ── Code Blocks ── */

pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 28px;
  overflow-x: auto;
  margin: 24px 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.85;
  box-shadow: var(--shadow-lg);
  position: relative;
}

pre .highlight-kw { color: #c084fc; }     /* let, fn, pub, async */
pre .highlight-str { color: #fb923c; }    /* strings */
pre .highlight-num { color: #22d3ee; }    /* numbers */
pre .highlight-cmt { color: #64748b; font-style: italic; } /* comments */
pre .highlight-ty  { color: #67e8f9; }    /* types */

/* ── Tables ── */

.table-wrap {
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin: 20px 0;
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  padding: 14px 18px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 13px 18px;
  border-top: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-secondary);
}

tr:first-child td { border-top: none; }
tr:hover td { background: var(--surface-soft); }

/* ── Module Cards ── */

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: 0.2s;
}

.module-card:hover {
  border-color: var(--accent-mid);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.module-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.module-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.module-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 10px;
}

/* ── Struct Fields (API Docs) ── */

.struct-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.struct-field:last-child { border-bottom: none; }

.field-name {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-dark);
  white-space: nowrap;
  min-width: 120px;
}

.field-type {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.field-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* ── Param Grid (Config docs) ── */

.param-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 16px 0;
}

.param-card-half {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
}

.param-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
}

.param-default {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-soft);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--mono);
}

.param-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  width: 100%;
  margin-top: 2px;
}

/* ── Math Blocks ── */

.math-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin: 20px 0;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  text-align: center;
  line-height: 1.9;
  box-shadow: var(--shadow-sm);
}

/* ── Principles Table ── */

.table-wrap table tr td:first-child {
  font-weight: 600;
  color: var(--text);
}

/* ── Misc ── */

strong {
  color: var(--text);
}

em {
  color: var(--text-secondary);
}

img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

/* ── Responsive ── */

/* ── Landing Page ── */

.lp-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(244, 246, 251, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.lp-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lp-logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.lp-nav-links {
  display: flex;
  gap: 28px;
  align-items: center;
}

.lp-nav-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: 0.15s;
}

.lp-nav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.lp-hero {
  position: relative;
  padding: 140px 24px 80px;
  text-align: center;
  overflow: hidden;
}

.lp-hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-soft) 0%, transparent 60%);
  pointer-events: none;
}

.lp-hero-inner {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.lp-hero-title {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1.1;
  margin-bottom: 20px;
  color: var(--text);
  display: block;
}

.lp-accent {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lp-hero-sub {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

.lp-hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.lp-btn {
  display: inline-block;
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: 0.2s;
}

.lp-btn-primary {
  background: var(--accent);
  color: #fff;
}

.lp-btn-primary:hover {
  background: var(--accent-dark);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.lp-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.lp-btn-secondary:hover {
  border-color: var(--accent-mid);
  text-decoration: none;
  transform: translateY(-1px);
}

.lp-hero-meta {
  margin-top: 40px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  justify-content: center;
}

.lp-section {
  padding: 80px 24px;
}

.lp-section-dark {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.lp-section-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.lp-section-title {
  font-size: 34px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 48px;
  letter-spacing: -0.5px;
}

.lp-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.lp-feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: 0.2s;
}

.lp-feature:hover {
  border-color: var(--accent-mid);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.lp-feature-icon {
  font-size: 24px;
  margin-bottom: 12px;
}

.lp-feature h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
}

.lp-feature p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

.lp-code-block {
  max-width: 720px;
  margin: 0 auto 20px;
}

.lp-code-tabs {
  display: flex;
  gap: 0;
  background: #1e293b;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px 20px 0;
}

.lp-code-tab {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  padding: 8px 16px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: default;
}

.lp-code-tab.active {
  background: #0f172a;
  color: #e2e8f0;
}

.lp-code {
  margin: 0 0 24px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.lp-section-cta {
  text-align: center;
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 24px;
}

.lp-footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  text-align: center;
}

.lp-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.lp-footer-links {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 16px;
}

.lp-footer-links a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
}

.lp-footer-links a:hover {
  color: var(--accent);
}

.lp-footer-copy {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ── Copy Button ── */

.copy-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: #334155;
  color: #cbd5e1;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: #475569;
  color: #f1f5f9;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .doc-wrap {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 28px 20px;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 22px;
    margin-top: 40px;
  }

  .pipeline-flow {
    flex-direction: column;
    gap: 8px;
  }

  .pf-arrow {
    transform: rotate(90deg);
  }

  .struct-field {
    flex-direction: column;
    gap: 2px;
  }

  .field-name {
    min-width: unset;
  }

  .lp-features {
    grid-template-columns: 1fr;
  }

  .lp-hero-title {
    font-size: 36px;
  }

  .lp-hero-sub {
    font-size: 16px;
  }

  .lp-nav-links {
    gap: 16px;
  }

  .lp-section-title {
    font-size: 26px;
  }
}
