/* ─── Design Tokens ─── */
:root {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-card: #1C2128;
  --bg-card-hover: #21262D;
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #484F58;
  --accent: #6C5CE7;
  --accent-hover: #5A4BD1;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --accent-2: #0984E3;
  --border: #30363D;
  --border-light: #21262D;
  --success: #10B981;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.15);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
code {
  font-family: var(--mono);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent);
}

/* ─── Nav ─── */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: transparent;
  transition: background var(--transition), backdrop-filter var(--transition), box-shadow var(--transition);
}
#navbar.scrolled {
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 1px 0 var(--border);
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
}
.logo-icon { font-size: 1.4rem; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}
.nav-links a:hover { color: var(--text-primary); }
.btn-nav {
  background: var(--accent) !important;
  color: #fff !important;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600 !important;
  transition: background var(--transition), transform var(--transition) !important;
}
.btn-nav:hover {
  background: var(--accent-hover) !important;
  transform: translateY(-1px);
}
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.mobile-menu-btn span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.mobile-menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ─── Hero ─── */
#hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 24px 48px;
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hero-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(108, 92, 231, 0.15), transparent),
    radial-gradient(ellipse 60% 80% at 80% 60%, rgba(9, 132, 227, 0.1), transparent),
    radial-gradient(ellipse 40% 40% at 20% 80%, rgba(108, 92, 231, 0.08), transparent);
}
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(48, 54, 61, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 54, 61, 0.3) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black, transparent);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black, transparent);
}
.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 800px;
  margin-bottom: 40px;
}
.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: rgba(108, 92, 231, 0.1);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}
#hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}
.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 580px;
  margin: 0 auto 24px;
  line-height: 1.7;
}
.hero-cta {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(108, 92, 231, 0.4);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
  color: var(--text-primary);
  transform: translateY(-2px);
}
.btn-icon { font-size: 0.9em; }
.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}
.stat { text-align: center; }
.stat-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

/* ─── Hero Playground ─── */
.hero-playground {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--max-width);
  margin-top: 8px;
}
.playground-label {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

/* ─── Sections ─── */
.section { padding: 100px 24px; }
.section-dark { background: var(--bg-secondary); }
.container {
  max-width: var(--max-width);
  margin: 0 auto;
}
.section-header {
  text-align: center;
  margin-bottom: 56px;
}
.section-header h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.section-header p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ─── Playground ─── */
.playground-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toolbar-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}
.toolbar-select {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.toolbar-select:focus { border-color: var(--accent); }
.toolbar-btn {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.toolbar-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.toolbar-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.playground-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--border);
  box-shadow: var(--shadow), var(--shadow-glow);
  min-height: 420px;
}
.playground-editor, .playground-canvas {
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}
.editor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.editor-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.canvas-dot { background: var(--success); }
#fd-editor {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.7;
  padding: 16px 20px;
  tab-size: 2;
}
#canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#fd-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ─── Canvas Tool Buttons ─── */
.canvas-tools {
  display: flex;
  gap: 2px;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 2px;
}
.canvas-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}
.canvas-tool:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.canvas-tool.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.zoom-indicator {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  padding: 2px 6px;
  user-select: none;
}

/* ─── Floating Action Bar ─── */
.fab {
  display: none;
  position: absolute;
  z-index: 20;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(22, 27, 34, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  transform: translateX(-50%);
  white-space: nowrap;
}
.fab.visible { display: flex; }
.fab-item {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.fab-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.fab-color {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.fab-color::-webkit-color-swatch-wrapper { padding: 0; }
.fab-color::-webkit-color-swatch { border-radius: 50%; border: none; }
.fab-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
}
.fab-delete {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 8px;
  font-size: 12px;
  transition: all 0.15s ease;
}
.fab-delete:hover {
  background: rgba(255, 59, 48, 0.15);
  border-color: rgba(255, 59, 48, 0.3);
  color: #FF3B30;
}

/* ─── Skeleton Loader ─── */
.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--bg-card);
}
.canvas-loading.hidden { display: none; }

.skeleton-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 160px;
}
.skeleton-shape {
  background: linear-gradient(90deg,
    var(--border) 25%,
    var(--bg-card-hover) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-rect {
  width: 120px;
  height: 60px;
  border-radius: var(--radius);
}
.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  animation-delay: 0.2s;
}
.skeleton-line {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  animation-delay: 0.4s;
}
.skeleton-line-short {
  width: 70%;
  animation-delay: 0.6s;
}
.loading-text {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ─── Features ─── */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}
.feature-card {
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
}
.feature-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}
.feature-icon {
  font-size: 2rem;
  margin-bottom: 16px;
}
.feature-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.feature-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ─── Modes ─── */
.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}
.mode-card {
  padding: 36px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
}
.mode-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}
.mode-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.mode-card h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.mode-card p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}
.mode-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mode-list li {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding-left: 20px;
  position: relative;
}
.mode-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* ─── Benchmarks ─── */
.benchmark-table-wrap { overflow-x: auto; }
.benchmark-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.benchmark-table th, .benchmark-table td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.benchmark-table thead th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.benchmark-table tbody tr { transition: background var(--transition); }
.benchmark-table tbody tr:hover { background: var(--bg-card); }
.ratio {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  font-weight: 700;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.ratio-avg {
  font-size: 1rem;
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent);
}
.benchmark-table tfoot td {
  border-top: 2px solid var(--border);
  font-weight: 700;
}

/* ─── Architecture ─── */
.arch-diagram {
  margin-bottom: 48px;
  overflow-x: auto;
}
.arch-ascii {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  text-align: center;
  white-space: pre;
  display: inline-block;
  width: 100%;
}
.crate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.crate-card {
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  transition: all var(--transition);
}
.crate-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.crate-card h4 {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}
.crate-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ─── Editor Table ─── */
.editor-table-wrap { overflow-x: auto; }
.editor-table {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  border-collapse: collapse;
}
.editor-table th, .editor-table td {
  padding: 14px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.editor-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.editor-table td:first-child { text-align: left; font-weight: 500; }

/* ─── CTA ─── */
.cta-container {
  text-align: center;
  max-width: 600px;
}
.cta-container h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.cta-container p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 32px;
}

/* ─── Footer ─── */
#footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.footer-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--text-primary); }
.footer-copy {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer-copy a {
  color: var(--text-secondary);
}

/* ─── Animations ─── */
.animate-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.animate-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    flex-direction: column;
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(20px);
    padding: 20px;
    gap: 16px;
    border-bottom: 1px solid var(--border);
  }
  .nav-links.open { display: flex; }
  .mobile-menu-btn { display: flex; }

  #hero {
    padding: 72px 16px 32px;
  }

  .playground-split {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .playground-editor { min-height: 280px; }
  .playground-canvas { min-height: 320px; }

  .hero-stats { gap: 16px; }
  .stat-divider { display: none; }

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

  #hero h1 { font-size: 2rem; }
  .hero-sub { font-size: 1rem; }

  .playground-label { display: none; }
}

@media (max-width: 480px) {
  .crate-grid { grid-template-columns: 1fr; }
  .section { padding: 60px 16px; }
}
