@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;

  --accent: #f59e0b;

  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0284c7;
  --info-light: #e0f2fe;

  /* Legacy variable aliases */
  --primary-color: #2563eb;
  --secondary-color: #3b82f6;
  --accent-color: #f59e0b;
  --text-color: #0f172a;
  --light-text: #64748b;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --success-color: #16a34a;
  --warning-color: #d97706;
  --danger-color: #dc2626;
  --info-color: #0284c7;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.09), 0 2px 4px -2px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--header-height, 64px) + 1rem);
  scroll-behavior: smooth;
}

[id] {
  scroll-margin-top: calc(var(--header-height, 64px) + 1rem);
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   HEADER
   ============================================================ */
header,
.header {
  background: #0f172a;
  color: #f8fafc;
  padding: 2.5rem 1rem 2rem;
  position: relative;
  overflow: hidden;
}

header::before,
.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

header::after,
.header::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
}

header h1,
.header h1 {
  font-size: clamp(1.625rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #f8fafc;
  line-height: 1.2;
  position: relative;
}

header p,
.subtitle {
  font-size: 1rem;
  color: #94a3b8;
  margin-top: 0.5rem;
  font-weight: 400;
  max-width: 680px;
  line-height: 1.55;
  position: relative;
}

.back-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1rem;
  transition: color 0.15s ease;
  font-weight: 500;
  position: relative;
  min-height: 44px;
  padding: 0.25rem 0;
  touch-action: manipulation;
}

.back-link:hover {
  color: #f8fafc;
}

@media (hover: none) {
  .back-link:active {
    color: #f8fafc;
  }
}

/* ============================================================
   NAVIGATION
   ============================================================ */
nav,
.main-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.875rem 1.375rem;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, border-color 0.15s ease;
  letter-spacing: 0.01em;
  min-height: 44px;
  touch-action: manipulation;
}

.nav-link:hover {
  color: var(--text);
  border-bottom-color: var(--border-strong);
}

.nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

@media (hover: none) {
  .nav-link:active {
    background: var(--surface-alt);
  }
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
main,
.main-content {
  padding: 2.5rem 0 3rem;
}

/* ============================================================
   WORKFLOW PAGE LAYOUT (sidebar + content)
   ============================================================ */
.workflow-layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  gap: 2rem;
  align-items: start;
}

.workflow-sidebar {
  position: sticky;
  top: calc(var(--header-height, 64px) + 1rem);
  max-height: calc(100vh - var(--header-height, 64px) - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scrollbar-width: none;
}

.workflow-sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow);
}

.sidebar-other-nav {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.sidebar-heading {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0.25rem;
}

.sidebar-sections,
.sidebar-other {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-sections li,
.sidebar-other li {
  margin: 0;
}

.sidebar-sections a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0.3125rem calc(0.75rem - 3px);
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  line-height: 1.35;
  touch-action: manipulation;
}

.sidebar-sections a:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-left-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

.sidebar-sections a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

.sidebar-other a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0.3125rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  line-height: 1.35;
  touch-action: manipulation;
}

.sidebar-other a:hover {
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
}

@media (hover: none) {
  .sidebar-sections a:active {
    background: var(--primary-light);
  }

  .sidebar-other a:active {
    background: rgba(245, 158, 11, 0.15);
  }
}

.sidebar-nav a:focus-visible,
.sidebar-other-nav a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
  .workflow-layout {
    grid-template-columns: 1fr;
    position: relative;
  }

  /* Hide mobile sidebar container completely - use floating button instead */
  .workflow-sidebar {
    display: none;
  }

  /* Floating navigation button */
  .floating-nav-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 1000;
  }

  .floating-nav-btn {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--surface);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    touch-action: manipulation;
  }

  .floating-nav-btn:hover,
  .floating-nav-btn:focus-visible {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.05);
  }

  .floating-nav-btn:active {
    transform: scale(0.95);
  }

  .floating-nav-btn[aria-expanded="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
  }

  .floating-nav-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
  }

  /* Backdrop overlay */
  .panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
  }

  .panel-backdrop[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
  }

  /* Sidebar panels - right-side slide-in */
  .sidebar-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 85vw;
    max-width: 320px;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: block;
  }

  .sidebar-panel[aria-hidden="false"] {
    transform: translateX(0);
  }

  /* Panel sections */
  .sidebar-panel-content {
    padding: 1rem;
  }

  .sidebar-nav,
  .sidebar-other-nav {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
  }

  .sidebar-heading {
    padding: 0.75rem 1rem 0.5rem;
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
  }

  /* Section links - vertical stack, no horizontal scroll */
  .sidebar-sections {
    display: block;
    overflow: visible;
    gap: 0;
    padding: 0;
    scrollbar-width: none;
  }

  .sidebar-sections::-webkit-scrollbar {
    display: none;
  }

  .sidebar-sections li {
    margin: 0;
  }

  .sidebar-sections a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-bottom: none;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    line-height: 1.35;
    touch-action: manipulation;
    width: 100%;
  }

  .sidebar-sections a:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-left-color: color-mix(in srgb, var(--primary) 40%, transparent);
  }

  .sidebar-sections a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
  }

  /* Other workflow links - vertical stack */
  .sidebar-other-nav {
    margin-top: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .sidebar-other {
    display: block;
    overflow: visible;
    gap: 0;
    padding: 0;
  }

  .sidebar-other li {
    margin: 0;
  }

  .sidebar-other a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-radius: 0;
    background: transparent;
    border: none;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    line-height: 1.35;
    touch-action: manipulation;
    width: 100%;
  }

  .sidebar-other a:hover {
    background: var(--surface-alt);
    color: var(--text);
    padding-left: 1.25rem;
  }

  /* Hide desktop-only elements on mobile */
  .sidebar-desktop {
    display: none;
  }

  /* Show mobile toggles on mobile */
  .sidebar-mobile-toggles {
    display: flex;
  }

  /* Add padding to main content to account for fixed sidebar */
  .workflow-detail {
    padding-bottom: 100px;
  }

  /* Panel header */
  .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .panel-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
  }

  .panel-close {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: none;
    background: var(--surface-alt);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    touch-action: manipulation;
  }

  .panel-close:hover,
  .panel-close:focus-visible {
    background: var(--primary-light);
    color: var(--primary);
  }

  .panel-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  /* Panel tabs */
  .panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 73px;
    z-index: 1;
  }

  .panel-tab {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    touch-action: manipulation;
    position: relative;
  }

  .panel-tab[aria-selected="true"] {
    color: var(--primary);
    border-bottom-color: var(--primary);
  }

  .panel-tab:hover,
  .panel-tab:focus-visible {
    background: var(--surface-alt);
  }

  .panel-tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
  }

  /* Panel content */
  .panel-content {
    padding: 1rem;
    display: block;
  }

  .panel-content--hidden {
    display: none;
  }

  /* Panel content - nav styles */
  .panel-content .sidebar-nav,
  .panel-content .sidebar-other-nav {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
  }

  .panel-content .sidebar-heading {
    padding: 0.75rem 1rem 0.5rem;
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
  }

  /* Hide hover states on touch devices */
  @media (hover: none) {
    .floating-nav-btn:active {
      transform: scale(0.95);
    }

    .panel-close:active {
      background: var(--primary-light);
      color: var(--primary);
    }

    .sidebar-sections a:active {
      background: var(--primary-light);
    }

    .sidebar-other a:active {
      background: var(--surface-alt);
    }
  }

  /* Focus states for accessibility */
  .sidebar-nav a:focus-visible,
  .sidebar-other-nav a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
  }

  /* Hide desktop-only elements on mobile */
  .sidebar-desktop {
    display: none;
  }

  /* Hide old mobile elements */
  .sidebar-mobile-toggles {
    display: none;
  }

  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    .sidebar-panel {
      transition: none;
    }

    .panel-backdrop {
      transition: none;
    }

    .floating-nav-btn {
      transition: none;
    }

    .sidebar-sections a,
    .sidebar-other a,
    .panel-tab,
    .panel-close {
      transition: none;
    }
  }
}

/* Desktop styles - restore original layout */
@media (min-width: 769px) {
  .workflow-sidebar {
    position: sticky;
    top: calc(var(--header-height, 64px) + 1rem);
    max-height: calc(100vh - var(--header-height, 64px) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scrollbar-width: none;
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    bottom: auto;
    left: auto;
    right: auto;
  }

  .workflow-sidebar::-webkit-scrollbar {
    display: none;
  }

  /* Hide mobile elements on desktop */
  .sidebar-mobile-toggles {
    display: none;
  }

  .sidebar-panel {
    display: none !important;
  }

  /* Hide floating navigation on desktop */
  .floating-nav-container {
    display: none !important;
  }

  .panel-backdrop {
    display: none !important;
  }

  /* Show desktop sidebar */
  .sidebar-desktop {
    display: block;
  }

  /* Restore desktop sidebar nav styles */
  .sidebar-nav {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    box-shadow: var(--shadow);
  }

  .sidebar-other-nav {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
  }

  .sidebar-heading {
    width: auto;
    margin: 0 0 0.5rem 0.25rem;
    font-size: 0.6875rem;
    padding: 0;
    border: none;
  }

  .sidebar-sections {
    display: block;
    overflow: visible;
    padding: 0;
  }

  .sidebar-sections a {
    min-height: 36px;
    padding: 0.3125rem calc(0.75rem - 3px);
    border-left: 3px solid transparent;
    border-bottom: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    display: flex;
    width: auto;
  }

  .sidebar-sections a:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-left-color: color-mix(in srgb, var(--primary) 40%, transparent);
  }

  .sidebar-sections a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
  }

  .sidebar-other {
    display: block;
    overflow: visible;
  }

  .sidebar-other a {
    min-height: 36px;
    padding: 0.3125rem 0.625rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    display: flex;
    width: auto;
  }

  .sidebar-other a:hover {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    padding-left: 0.625rem;
  }

  /* Remove padding from main content on desktop */
  .workflow-detail {
    padding-bottom: 0;
  }
}

section {
  margin-bottom: 2.5rem;
}

h2 {
  color: var(--text);
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

h3 {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.875rem;
}

h4 {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* ============================================================
   WORKFLOW CARDS (index page)
   ============================================================ */
.workflows-grid,
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.375rem;
}

.workflow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.625rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

@media (hover: hover) {
  .workflow-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #93c5fd;
  }
}

.workflow-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.015em;
}

.workflow-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.015em;
}

.workflow-description,
.workflow-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  flex: 1;
}

.workflow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.meta-item {
  font-size: 0.72rem;
  font-family: 'Space Mono', monospace;
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn,
.explore-btn,
.compare-btn {
  display: inline-block;
  padding: 0.55rem 1.125rem;
  border-radius: var(--radius-sm);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  line-height: 1.4;
  border: none;
  text-align: center;
  align-self: flex-start;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary,
.explore-btn,
.compare-btn {
  background-color: var(--primary);
  color: #fff !important;
}

.btn-primary:hover,
.explore-btn:hover,
.compare-btn:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  color: #fff !important;
}

.btn-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.775rem;
  touch-action: manipulation;
}

@media (hover: none) {
  .btn:active,
  .btn-primary:active,
  .explore-btn:active,
  .compare-btn:active {
    background-color: var(--primary-dark);
    transform: scale(0.97);
  }
}

/* ============================================================
   FOOTER
   ============================================================ */
footer,
.footer {
  background: #0f172a;
  color: #475569;
  padding: 1.75rem 0;
  margin-top: 3.5rem;
  border-top: 1px solid #1e293b;
}

footer p,
.footer p {
  text-align: center;
  font-size: 0.85rem;
}

footer p strong,
.footer p strong {
  color: #94a3b8;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
}

/* ============================================================
   WORKFLOW DETAIL - SECTION CARDS
   ============================================================ */
.section,
.workflow-detail section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.375rem;
  box-shadow: var(--shadow);
}

.section h2,
.workflow-detail section h2 {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-subtle);
  margin-bottom: 1.125rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.09em;
}

/* ============================================================
   USE CASES
   ============================================================ */
.use-cases {
  list-style: none;
  display: grid;
  gap: 0.25rem;
}

.use-cases li {
  padding: 0.45rem 0 0.45rem 1.75rem;
  position: relative;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.use-cases li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
  font-family: 'Space Mono', monospace;
}

/* ============================================================
   COMPONENTS
   ============================================================ */
.components,
.components-list {
  list-style: none;
  display: grid;
  gap: 0.625rem;
}

.components li,
.component-item {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.components li strong {
  color: var(--primary-dark);
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  background: var(--primary-light);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.35rem;
}

/* ============================================================
   STEPS
   ============================================================ */
.steps,
.steps-list {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 0.625rem;
}

.steps li,
.steps-list li {
  counter-increment: step;
  padding: 0.875rem 1rem 0.875rem 3.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.steps li::before,
.steps-list li::before {
  content: counter(step);
  position: absolute;
  left: 0.875rem;
  top: 0.9rem;
  width: 1.625rem;
  height: 1.625rem;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
  font-family: 'Space Mono', monospace;
}

.steps li strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.875rem;
}

/* ============================================================
   GOTCHAS
   ============================================================ */
.gotchas,
.gotchas-list {
  list-style: none;
  display: grid;
  gap: 0.625rem;
}

.gotchas li,
.gotcha-item {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  font-size: 0.875rem;
  line-height: 1.55;
}

.gotcha-critical,
.gotcha-item.severity-critical {
  border-left-color: var(--danger);
  background: var(--danger-light);
  color: #7f1d1d;
}

.gotcha-important,
.gotcha-item.severity-important {
  border-left-color: var(--warning);
  background: var(--warning-light);
  color: #78350f;
}

.gotcha-mild,
.gotcha-item.severity-mild {
  border-left-color: var(--info);
  background: var(--info-light);
  color: #075985;
}

.gotchas li strong {
  display: block;
  margin-bottom: 0.15rem;
  font-weight: 700;
}

.severity-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  border-radius: 100px;
  margin-left: 0.4rem;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.gotcha-critical .severity-badge { background: var(--danger); color: #fff; }
.gotcha-important .severity-badge { background: var(--warning); color: #fff; }
.gotcha-mild .severity-badge { background: var(--info); color: #fff; }

/* ============================================================
   BEST PRACTICES
   ============================================================ */
.best-practices {
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.best-practices li {
  padding: 0.4rem 0 0.4rem 1.75rem;
  position: relative;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.best-practices li::before {
  content: '🏅';
  position: absolute;
  left: 0;
}

/* ============================================================
   REAL-WORLD EXAMPLES
   ============================================================ */
.real-world-examples {
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.real-world-example {
  padding: 0.875rem 1rem;
  background: var(--surface-raised);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.real-world-example strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

/* ============================================================
   PROS / CONS
   ============================================================ */
.pros-cons,
.pros-cons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.pros {
  background: var(--success-light);
  border: 1px solid #bbf7d0;
  padding: 1.375rem;
  border-radius: var(--radius-sm);
}

.cons {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  padding: 1.375rem;
  border-radius: var(--radius-sm);
}

.pros h3 {
  color: var(--success);
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'Space Mono', monospace;
}

.cons h3 {
  color: var(--danger);
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'Space Mono', monospace;
}

.pros ul,
.cons ul {
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.pros li,
.cons li {
  font-size: 0.875rem;
  padding-left: 1.25rem;
  position: relative;
  color: var(--text);
}

.pros li::before {
  content: '+';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
  font-family: 'Space Mono', monospace;
}

.cons li::before {
  content: '\2212';
  position: absolute;
  left: 0;
  color: var(--danger);
  font-weight: 700;
  font-family: 'Space Mono', monospace;
}

/* ============================================================
   DIAGRAM
   ============================================================ */

/* Toggle group — editor-tab metaphor */
.diagram-view-toggle {
  display: inline-flex;
  align-items: stretch;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  margin-bottom: 1.25rem;
}

.diagram-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease,
              box-shadow 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.diagram-tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}

.diagram-tab.active {
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  border-color: var(--border);
  border-top: 2px solid var(--primary);
  padding-top: calc(0.375rem - 1px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.diagram-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  z-index: 1;
}

@media (hover: none) {
  .diagram-tab:active:not(.active) {
    background: rgba(255, 255, 255, 0.55);
  }
}

/* Panel visibility */
.diagram-panel--hidden {
  display: none;
}

@keyframes panelFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.diagram-panel {
  animation: panelFadeIn 0.12s ease both;
}

/* Container */
.diagram-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  min-width: 0;
}

.diagram {
  background: #0f172a;
  color: #7dd3fc;
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid #1e293b;
  min-width: 600px;
}

/* Mermaid SVG panel */
.mermaid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mermaid svg {
  max-width: 100%;
  height: auto !important;
  display: block;
  min-width: 300px;
}

/* ============================================================
   FRAME PLAYER
   ============================================================ */

.frame-player {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* aspect-ratio locks container to 900:360 — eliminates layout shift between frames */
.frame-player__stage {
  width: 100%;
  aspect-ratio: 900 / 360;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.frame-player__frame {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  touch-action: manipulation;
}

.frame-player__chrome {
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
}

.frame-player__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.frame-player__btn--step,
.frame-player__btn--play {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  flex-shrink: 0;
  line-height: 1;
  touch-action: manipulation;
}

.frame-player__btn--step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  padding: 0;
}

.frame-player__btn--step:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--primary);
  background: var(--primary-light);
}

.frame-player__btn--step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.frame-player__btn--play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.1s ease;
  padding: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.frame-player__btn--play:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.frame-player__btn--play:active {
  transform: scale(0.97);
}

@media (hover: none) {
  .frame-player__btn--step:active:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--text);
  }

  .frame-player__btn--play:active {
    background: var(--primary-dark);
    transform: scale(0.97);
  }
}

.frame-player__btn--step:focus-visible,
.frame-player__btn--play:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.frame-player__track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}

.frame-player__dots {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.frame-player__dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--border-strong);
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  flex-shrink: 0;
  touch-action: manipulation;
}

.frame-player__dot::before {
  content: '';
  position: absolute;
  inset: -6px;
}

.frame-player__dot:hover {
  background: var(--text-muted);
  transform: scale(1.25);
}

.frame-player__dot.is-visited {
  background: #93c5fd;
}

.frame-player__dot.is-active {
  background: var(--primary);
  transform: scale(1.4);
  box-shadow: 0 0 0 2.5px var(--primary-light);
}

.frame-player__dot:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

@media (hover: none) {
  .frame-player__dot:active {
    transform: scale(1.3);
  }
}

.frame-player__label {
  font-family: 'Space Mono', monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  text-align: center;
  line-height: 1;
}

@media (max-width: 640px) {
  .diagram-tab {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    min-height: 44px;
  }

  /* Frame player - adjust for smaller screens */
  .frame-player__stage {
    aspect-ratio: 16 / 9;
  }

  .frame-player__chrome {
    padding: 0.625rem 1rem;
  }

  .frame-player__btn--step {
    width: 40px;
    height: 40px;
  }

  .frame-player__btn--play {
    width: 48px;
    height: 48px;
  }

  .frame-player__dots {
    gap: 6px;
  }

  .frame-player__dot {
    width: 9px;
    height: 9px;
  }

  .frame-player__label {
    font-size: 0.65rem;
  }

  /* Better spacing on small screens */
  .section,
  .workflow-detail section {
    padding: 1rem;
  }

  /* Workflow cards - tighter spacing */
  .workflow-card,
  .comparison-card,
  .decision-card {
    padding: 1.125rem;
  }

  /* Meta tags - smaller on mobile */
  .meta-item {
    font-size: 0.68rem;
    padding: 0.15rem 0.5rem;
  }

  /* Steps - tighter spacing */
  .steps li,
  .steps-list li {
    padding: 0.75rem 0.875rem 0.75rem 2.75rem;
    font-size: 0.85rem;
  }

  /* Gotchas - tighter spacing */
  .gotchas li,
  .gotcha-item {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .diagram-tab,
  .frame-player__btn--step,
  .frame-player__btn--play,
  .frame-player__dot {
    transition: none;
  }
  .diagram-panel {
    animation: none;
  }
}

/* ============================================================
   COMPARISON TABLE (compare page)
   ============================================================ */
.comparison-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2.5rem;
}

.comparison-table table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.comparison-table th {
  background: #0f172a;
  color: #94a3b8;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-bottom: 1px solid #1e293b;
  position: sticky;
  top: 0;
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

@media (hover: hover) {
  .comparison-table tr:hover td {
    background: var(--surface-alt);
  }
}

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

.comparison-table a,
.comparison-table a:visited {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.comparison-table a:hover {
  text-decoration: underline;
}

/* Custom scrollbar for horizontal scroll */
.comparison-table::-webkit-scrollbar {
  height: 8px;
}

.comparison-table::-webkit-scrollbar-track {
  background: var(--surface-alt);
  border-radius: 4px;
}

.comparison-table::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.comparison-table::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   COMPARISON CARDS (compare page)
   ============================================================ */
.comparison-summary {
  margin-top: 1rem;
}

.comparison-summary h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.comparison-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.125rem;
}

.comparison-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

@media (hover: hover) {
  .comparison-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #93c5fd;
  }
}

.comparison-card h3 {
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  margin-bottom: 1.125rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label,
.stat .label {
  font-size: 0.65rem;
  font-family: 'Space Mono', monospace;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value,
.stat .value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

/* ============================================================
   DECISION GUIDE (compare page)
   ============================================================ */
.decision-guide {
  margin-top: 1rem;
}

.decision-guide h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.decision-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.125rem;
}

.decision-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (hover: hover) {
  .decision-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #93c5fd;
  }
}

.decision-icon {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.decision-card h3 {
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.decision-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 0.625rem;
}

/* ============================================================
   ERROR PAGE (404)
   ============================================================ */
.error-page {
  text-align: center;
  padding: 5rem 2rem;
}

.error-page h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.error-page p {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.error-page a {
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .container { padding: 0 16px; }

  header h1,
  .header h1 { font-size: 1.5rem; }

  header,
  .header { padding: 2rem 1rem 1.5rem; }

  .subtitle { font-size: 0.9rem; }

  /* Navigation - better touch targets */
  nav,
  .main-nav {
    justify-content: center;
  }

  .nav-link {
    padding: 1rem 1.5rem;
    font-size: 0.9rem;
  }

  .workflows-grid,
  .workflow-grid,
  .comparison-cards,
  .decision-cards { grid-template-columns: 1fr; }

  .pros-cons,
  .pros-cons-grid { grid-template-columns: 1fr; }

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

  .section,
  .workflow-detail section { padding: 1.25rem; }

  .comparison-table th,
  .comparison-table td { padding: 0.75rem 0.875rem; font-size: 0.85rem; }

  /* Workflow cards - better touch spacing */
  .workflow-card,
  .comparison-card,
  .decision-card {
    padding: 1.375rem;
  }

  /* Buttons - minimum 44px touch targets */
  .btn,
  .btn-primary,
  .btn-small {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
  }

  .btn-small {
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
  }

  /* Frame player - larger touch targets */
  .frame-player__btn--step {
    width: 44px;
    height: 44px;
  }

  .frame-player__btn--play {
    width: 52px;
    height: 52px;
  }

  .frame-player__dots {
    gap: 8px;
  }

  .frame-player__dot {
    width: 10px;
    height: 10px;
  }

  .frame-player__dot::before {
    inset: -8px;
  }

  /* Diagram tabs - larger touch targets */
  .diagram-tab {
    padding: 0.5rem 0.875rem;
    font-size: 0.85rem;
    min-height: 44px;
  }

  /* Error page - better spacing */
  .error-page {
    padding: 3rem 1rem;
  }

  .error-page h2 {
    font-size: 1.5rem;
  }

  /* Footer - better spacing */
  footer,
  .footer {
    padding: 1.5rem 0;
  }

  footer p,
  .footer p {
    font-size: 0.8rem;
  }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Extra small mobile devices */
@media (max-width: 375px) {
  .container { padding: 0 12px; }

  header h1,
  .header h1 { font-size: 1.375rem; }

  .subtitle { font-size: 0.85rem; }

  .nav-link {
    padding: 0.875rem 1rem;
    font-size: 0.85rem;
  }

  .btn,
  .btn-primary,
  .btn-small {
    padding: 0.625rem 1rem;
    font-size: 0.8rem;
    min-height: 44px;
  }

  .frame-player__btn--step {
    width: 40px;
    height: 40px;
  }

  .frame-player__btn--play {
    width: 44px;
    height: 44px;
  }

  .diagram-tab {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    min-height: 44px;
  }

  .section,
  .workflow-detail section {
    padding: 0.875rem;
  }

  .workflow-card,
  .comparison-card,
  .decision-card {
    padding: 1rem;
  }

  .workflow-name,
  .workflow-card h3 {
    font-size: 0.95rem;
  }

  .workflow-description,
  .workflow-card p {
    font-size: 0.85rem;
  }
}
