:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dark theme colors (default) */
  --bg-main: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-card: rgba(23, 33, 56, 0.7);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(6, 182, 212, 0.4);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #38bdf8;
  --text-accent-glow: #0ea5e9;

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-purple: #a855f7;
  --accent-orange: #f97316;

  --sidebar-w: 280px;
  --header-h: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 25px rgba(6, 182, 212, 0.2);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Top Navigation Bar */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
}

.nav-container {
  max-width: 1560px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Brand */
.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.brand-title {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
}

/* Pill Selectors */
.pill-selector {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pill-btn:hover {
  color: var(--text-primary);
}

.pill-btn.active {
  background: var(--accent-cyan);
  color: #03131e;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

.pill-icon, .flag-icon {
  font-size: 0.95rem;
}

/* Action buttons */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-outline {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.3);
}

.btn-outline:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
  padding: 0.4rem;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}

.sidebar-toggle-btn {
  display: none;
}

/* Layout */
.app-layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
  max-width: 1560px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-main);
  scrollbar-width: thin;
}

.sidebar-inner {
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar-doc-label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.toc-item {
  display: block;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-item.level-2 {
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 0.35rem;
}

.toc-item.level-3 {
  padding-left: 1.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.toc-item:hover {
  color: var(--text-accent);
  background: rgba(6, 182, 212, 0.06);
}

.toc-item.active {
  color: var(--accent-cyan);
  font-weight: 600;
  border-left-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.sidebar-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.doc-meta-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
}

.meta-label {
  color: var(--text-muted);
}

.meta-val {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Content Area */
.content-area {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 3.5rem;
}

.content-container {
  max-width: 900px;
  margin: 0 auto;
}

/* Loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem 0;
  color: var(--text-muted);
  gap: 1rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(6, 182, 212, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Markdown Rendering Engine Styling */
.markdown-body {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--text-primary);
}

.markdown-body h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 1rem;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.markdown-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.markdown-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 1.8rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.markdown-body p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}

.markdown-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.markdown-body hr {
  margin: 2.5rem 0;
  border: 0;
  height: 1px;
  background: var(--border-subtle);
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.markdown-body li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.markdown-body a {
  color: var(--accent-cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(6, 182, 212, 0.3);
  transition: all var(--transition-fast);
}

.markdown-body a:hover {
  border-bottom-color: var(--accent-cyan);
  color: var(--text-accent);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-sans);
}

.markdown-body td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Code Blocks */
.code-block-container {
  position: relative;
  margin: 1.5rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #111827;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.85rem;
  background: #1e293b;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.copy-code-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.markdown-body pre {
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
}

.markdown-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  color: var(--accent-cyan);
  border: 1px solid var(--border-subtle);
}

/* Images */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin: 1.5rem 0;
  display: block;
  box-shadow: var(--shadow-subtle);
}

/* Blockquotes */
.markdown-body blockquote {
  margin: 1.5rem 0;
  padding: 0.85rem 1.25rem;
  border-left: 4px solid var(--accent-cyan);
  background: rgba(6, 182, 212, 0.06);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Interactive Video Demo Cards */
.video-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.video-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.video-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 2;
}

.video-card:hover,
.video-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent-cyan);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  outline: none;
}

.video-card:hover::before,
.video-card:focus-visible::before {
  opacity: 1;
}

.video-card-thumb-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #000;
  overflow: hidden;
}

.video-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform var(--transition-normal);
  display: block;
}

.video-card:hover .video-card-thumb {
  transform: scale(1.04);
}

.video-card-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 19, 30, 0.35);
  transition: background var(--transition-fast);
}

.video-card:hover .video-card-play-overlay {
  background: rgba(3, 19, 30, 0.15);
}

.video-play-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(6, 182, 212, 0.9);
  color: #03131e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  padding-left: 3px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.video-card:hover .video-play-icon {
  transform: scale(1.12);
  background: var(--text-accent);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
}

.video-card-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(3, 19, 30, 0.85);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.35);
  backdrop-filter: blur(4px);
  white-space: nowrap;
  z-index: 1;
}

.video-card-body {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.video-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin: 0;
}

.video-card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

/* Content Footer */
.content-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
}

.footer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.footer-switch-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.footer-switch-btn:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-surface-elevated);
}

.footer-btn-sub {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.footer-btn-main {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.15rem;
}

.back-to-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.back-to-top-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}

.footer-credits {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Video Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.modal-container {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  z-index: 10;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border-radius: var(--radius-sm);
}

.modal-title-group h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  background: transparent;
  border: none;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.video-wrapper {
  width: 100%;
  max-height: 520px;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.video-wrapper video {
  width: 100%;
  max-height: 520px;
  height: auto;
  display: block;
}

.modal-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.video-filename-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 95;
    background: var(--bg-surface);
    transition: transform var(--transition-normal);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
  }

  .sidebar-backdrop.active {
    display: block;
  }

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

  .content-area {
    padding: 2rem 1.5rem;
  }

  .video-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .nav-container {
    padding: 0 0.75rem;
  }

  .brand-title {
    display: none;
  }

  .nav-center {
    display: none;
  }

  .pill-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
  }

  .btn-text {
    display: none;
  }
}
