/* ==========================================================================
   Pathway Analytics — Documentation Site Theme
   Conforms to the pwa-refactor application house style
   (packages/web/src/app.css): primary #1f4788, blue-600 accent, semantic
   surface/text/border tokens, light + dark via CSS-variable flip.
   ========================================================================== */

/* ==========================================================================
   1. CUSTOM PROPERTIES — house-style tokens (ported from pwa-refactor)
   ========================================================================== */

:root {
  /* Brand */
  --pa-primary: #1f4788;
  --pa-primary-hover: #163561;

  /* Semantic surfaces / text / borders (light) — pwa-refactor values */
  --pa-surface: #ffffff;          /* page background            */
  --pa-surface-raised: #ffffff;   /* cards / panels             */
  --pa-surface-sunken: #f3f4f6;   /* wells / inset areas / rows */
  --pa-surface-hover: #f9fafb;    /* row / control hover        */
  --pa-text: #111827;             /* gray-900 — primary body    */
  --pa-text-muted: #4b5563;       /* gray-600 — AA on white     */
  --pa-text-subtle: #6b7280;      /* gray-500 — hints/meta      */
  --pa-border: #e5e7eb;           /* gray-200                   */
  --pa-border-strong: #d1d5db;    /* gray-300                   */
  --pa-accent: #2563eb;           /* blue-600 — links / accent  */
  --pa-accent-hover: #1d4ed8;     /* blue-700                   */

  /* Status (brief §4) — ≥4.5:1 as text on surface-raised in light */
  --pa-success: #15803d;          /* green-700 */
  --pa-warning: #b45309;          /* amber-700 */
  --pa-danger:  #b91c1c;          /* red-700   */
  --pa-info:    #1d4ed8;          /* blue-700  */

  /* Docsify theme hook */
  --theme-color: var(--pa-primary);

  /* Spacing — 8px base scale */
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
  --space-lg: 32px;
  --space-xl: 48px;
  --space-2xl: 80px;

  /* Type */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --font-size-base: 16px;
  --line-height: 1.7;

  /* Radius (pwa-refactor design1: controls 6px, cards 8px) */
  --pa-radius-control: 6px;
  --pa-radius-card: 8px;

  --content-max-width: 1100px;
  --sidebar-width: 280px;
  --navbar-height: 64px;
}

/* Dark theme — pwa-refactor values, tuned for the near-black page bg */
html[data-theme="dark"] {
  --pa-surface: #111827;          /* gray-900 */
  --pa-surface-raised: #1f2937;   /* gray-800 */
  --pa-surface-sunken: #0b1220;
  --pa-surface-hover: #374151;    /* gray-700 */
  --pa-text: #f3f4f6;             /* gray-100 */
  --pa-text-muted: #cbd5e1;       /* slate-300 */
  --pa-text-subtle: #94a3b8;      /* slate-400 */
  --pa-border: #374151;           /* gray-700 */
  --pa-border-strong: #4b5563;    /* gray-600 */
  --pa-primary: #6aa7f8;
  --pa-primary-hover: #9dc4fb;
  --pa-accent: #60a5fa;           /* blue-400 */
  --pa-accent-hover: #93c5fd;     /* blue-300 */

  --pa-success: #4ade80;
  --pa-warning: #fbbf24;
  --pa-danger:  #f87171;
  --pa-info:    #93c5fd;

  --theme-color: var(--pa-primary);
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* Offset anchor/hash navigation so targets clear the fixed navbar.
   scroll-padding-top on the scroll root covers native :target jumps and
   modern programmatic scrollIntoView; the per-heading scroll-margin-top
   below is the belt-and-braces for the heading elements themselves. */
html {
  scroll-padding-top: calc(var(--navbar-height) + var(--space-md));
}

body, h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote { margin: 0; }

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: 400;
  line-height: var(--line-height);
  color: var(--pa-text);
  background-color: var(--pa-surface);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--pa-accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--pa-accent-hover); }

/* ==========================================================================
   3. NAVBAR
   ========================================================================== */

.app-nav,
nav.app-nav,
body.sticky .app-nav {
  position: fixed !important;
  top: 0 !important;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--navbar-height);
  width: 100%;
  display: flex !important;
  align-items: center;
  padding: 0 var(--space-lg);
  margin: 0 !important;
  background: var(--pa-surface) !important;
  border-bottom: 1px solid var(--pa-border);
  box-shadow: none;
}

.app-nav ul {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  gap: 0;
  flex-grow: 1;
}

.app-nav li { list-style: none !important; margin: 0; }

.app-nav a {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 0.85em;
  font-weight: 400;
  color: var(--pa-text-muted);
  letter-spacing: 0.02em;
  border-radius: var(--pa-radius-control);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.app-nav a:hover { color: var(--pa-primary); background: var(--pa-surface-hover); }

/* Navbar — first item styled as brand */
.app-nav li:first-child a {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9em;
  color: var(--pa-primary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-left: 0;
}

.app-nav li:first-child a:hover { color: var(--pa-primary); background: none; }

/* Push nav links to the right */
.app-nav li:first-child { margin-right: auto; }

/* Dark mode toggle — fixed top-right */
.dark-mode-toggle {
  position: fixed;
  top: 14px;
  right: var(--space-lg);
  z-index: 1100;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pa-surface-raised);
  color: var(--pa-text-muted);
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-control);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.dark-mode-toggle:hover {
  color: var(--pa-primary);
  border-color: var(--pa-border-strong);
  background: var(--pa-surface-hover);
}

/* ==========================================================================
   4. SIDEBAR  — now persistent across ALL sections
   ========================================================================== */

.sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  background-color: var(--pa-surface-sunken);
  border-right: 1px solid var(--pa-border);
  padding: var(--space-sm) 0;
  z-index: 900;
  display: block;
}

h1.app-name { display: none !important; }

/* Search — always mounted in the sidebar */
.search {
  padding: var(--space-xs) var(--space-sm) var(--space-sm);
  margin-bottom: var(--space-xs);
  border-bottom: 1px solid var(--pa-border);
}

.search .input-wrap { display: flex; align-items: center; }

.search input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.85em;
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-control);
  background: var(--pa-surface-raised);
  color: var(--pa-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search input:focus {
  border-color: var(--pa-accent) !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15) !important;
}

.search .clear-button { cursor: pointer; width: 28px; text-align: center; }
.search .results-panel { display: none; }
.search .results-panel.show { display: block; }
.search .matching-post { padding: 8px 0; border-bottom: 1px solid var(--pa-border); }
.search .matching-post:last-child { border-bottom: none; }
.search .matching-post a { color: var(--pa-accent); font-weight: 500; }
.search .matching-post p { font-size: 0.8em; color: var(--pa-text-muted); margin: 4px 0 0; }
.search p.empty { text-align: center; color: var(--pa-text-muted); font-size: 0.85em; }
.search h2 { font-size: 0.85em; margin: 10px 0 4px; color: var(--pa-text-muted); }

.search-highlight {
  background-color: rgba(37, 99, 235, 0.18);
  color: inherit;
  padding: 1px 3px;
  border-radius: 3px;
}

/* Sidebar nav */
.sidebar-nav { padding: var(--space-xs) var(--space-sm); }

.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav ul ul { padding-left: var(--space-sm); margin-top: 2px; }

.sidebar-nav li > a,
.sidebar-nav li > p > a {
  display: block;
  padding: 7px 10px;
  font-size: 0.86em;
  font-weight: 400;
  color: var(--pa-text-muted);
  text-decoration: none;
  border-radius: var(--pa-radius-control);
  transition: color 0.15s, background 0.15s;
  line-height: 1.4;
}

.sidebar-nav li > a:hover,
.sidebar-nav li > p > a:hover {
  color: var(--pa-primary);
  background-color: var(--pa-surface-hover);
}

.sidebar-nav li.active > a,
.sidebar-nav li > p.active > a,
.sidebar-nav li > p.active a {
  color: var(--pa-primary);
  font-weight: 600;
  background-color: rgba(31, 71, 136, 0.08);
}

.sidebar-nav li > p { margin: 0; padding: 0; }

/* Top-level group headings (bold rows) */
.sidebar-nav li > p > strong,
.sidebar-nav li > strong {
  display: block;
  padding: 8px 10px;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pa-text-subtle);
  cursor: pointer;
  border-radius: var(--pa-radius-control);
  transition: color 0.15s, background 0.15s;
  line-height: 1.4;
}

.sidebar-nav li > p > strong:hover,
.sidebar-nav li > strong:hover {
  color: var(--pa-primary);
  background-color: var(--pa-surface-hover);
}

/* Sub-sidebar (page headings) */
.app-sub-sidebar {
  list-style: none;
  padding: 0 0 0 var(--space-sm);
  margin: 2px 0 0;
}

.app-sub-sidebar a {
  display: block;
  padding: 4px 10px;
  font-size: 0.78em;
  color: var(--pa-text-subtle);
  border-radius: var(--pa-radius-control);
  transition: color 0.15s;
}

.app-sub-sidebar a:hover { color: var(--pa-primary); }

/* Collapsible sections */
.sidebar-nav li.collapsible { position: relative; }
.sidebar-nav li.collapsible > p { padding-right: 28px; }

.sidebar-nav li.collapsible > .collapse-toggle,
.sidebar-nav li.collapsible > p::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 12px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--pa-text-subtle);
  border-bottom: 1.5px solid var(--pa-text-subtle);
  transform: rotate(45deg);
  transition: transform 0.2s;
  pointer-events: none;
}

.sidebar-nav li.collapsible.collapsed > .collapse-toggle,
.sidebar-nav li.collapsible.collapsed > p::after {
  transform: rotate(-45deg);
}

.sidebar-nav li.collapsible > ul {
  overflow: hidden;
  max-height: 1200px;
  transition: max-height 0.25s ease;
}

.sidebar-nav li.collapsible.collapsed > ul { max-height: 0; }

/* Sidebar toggle button (mobile) */
.sidebar-toggle {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  z-index: 950;
  width: 44px;
  height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--pa-surface-raised);
  border: 1px solid var(--pa-border);
  border-radius: 0 var(--pa-radius-control) var(--pa-radius-control) 0;
  cursor: pointer;
  color: var(--pa-text-muted);
}

/* ==========================================================================
   5. CONTENT AREA  — always offset for the persistent sidebar
   ========================================================================== */

section.content,
.content {
  padding-top: calc(var(--navbar-height) + var(--space-lg)) !important;
  padding-left: var(--space-xl);
  padding-right: var(--space-xl);
  padding-bottom: var(--space-2xl);
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.2s ease;
}

.markdown-section { max-width: var(--content-max-width); margin: 0 auto; }

/* ==========================================================================
   6. TYPOGRAPHY
   ========================================================================== */

.markdown-section h1 {
  font-family: var(--font-body);
  font-size: 2em;
  font-weight: 700;
  color: var(--pa-primary);
  margin-top: 0;
  margin-bottom: var(--space-md);
  line-height: 1.2;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--navbar-height) + var(--space-md));
}

.markdown-section h2 {
  font-family: var(--font-body);
  font-size: 1.5em;
  font-weight: 700;
  color: var(--pa-primary);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--pa-border);
  line-height: 1.3;
  scroll-margin-top: calc(var(--navbar-height) + var(--space-md));
}

.markdown-section h3 {
  font-family: var(--font-body);
  font-size: 1.2em;
  font-weight: 600;
  color: var(--pa-text);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
  line-height: 1.4;
  scroll-margin-top: calc(var(--navbar-height) + var(--space-md));
}

.markdown-section h4 {
  font-family: var(--font-body);
  font-size: 1.05em;
  font-weight: 600;
  color: var(--pa-text);
  margin-top: var(--space-md);
  margin-bottom: var(--space-xs);
  scroll-margin-top: calc(var(--navbar-height) + var(--space-md));
}

.markdown-section h1 a,
.markdown-section h2 a,
.markdown-section h3 a,
.markdown-section h4 a { color: inherit !important; text-decoration: none; }

.markdown-section [id] { scroll-margin-top: calc(var(--navbar-height) + var(--space-md)); }

.markdown-section p { margin-bottom: var(--space-sm); color: var(--pa-text); }

.markdown-section ul,
.markdown-section ol { margin-bottom: var(--space-sm); padding-left: var(--space-md); }

.markdown-section li { margin-bottom: 6px; }

.markdown-section hr { border: none; border-top: 1px solid var(--pa-border); margin: var(--space-lg) 0; }

/* Code */
.markdown-section code {
  font-size: 0.85em;
  padding: 2px 6px;
  background: var(--pa-surface-sunken);
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-control);
  font-family: var(--font-mono);
  color: var(--pa-text);
}

.markdown-section pre {
  margin: var(--space-sm) 0;
  padding: var(--space-sm);
  background: #0b1220;
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-card);
  overflow-x: auto;
}

.markdown-section pre code {
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  font-size: 0.84em;
  line-height: 1.6;
  color: #e5e7eb;
}

/* Tables */
.markdown-section table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-sm) 0;
  font-size: 0.9em;
}

.markdown-section th {
  background: var(--pa-surface-sunken);
  color: var(--pa-text);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--pa-border);
}

.markdown-section td { padding: 10px 12px; border: 1px solid var(--pa-border); }

.markdown-section tr:nth-child(even) { background: var(--pa-surface-hover); }

/* Blockquotes */
.markdown-section blockquote {
  border-left: 3px solid var(--pa-accent);
  background: var(--pa-surface-sunken);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0;
  border-radius: 0 var(--pa-radius-control) var(--pa-radius-control) 0;
  font-style: normal;
  color: var(--pa-text);
}

.markdown-section blockquote p { margin-bottom: 0; }

/* Callouts (added by calloutPlugin based on label) */
.markdown-section blockquote.callout-note { border-left-color: var(--pa-warning); }
.markdown-section blockquote.callout-important { border-left-color: var(--pa-danger); }

/* ==========================================================================
   7. HOMEPAGE HERO & SECTIONS
   ========================================================================== */

.hero { padding: var(--space-2xl) 0 var(--space-xl); }

.hero .eyebrow {
  font-family: var(--font-body);
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pa-accent);
  margin-bottom: var(--space-md);
  display: block;
}

.hero h1 {
  font-family: var(--font-body) !important;
  font-size: 2.6em !important;
  font-weight: 700 !important;
  color: var(--pa-primary) !important;
  line-height: 1.15 !important;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-md) !important;
}

.hero h1 em { color: var(--pa-accent); font-style: normal; }

.hero .lead {
  font-size: 1.1em;
  color: var(--pa-text-muted);
  max-width: 560px;
  line-height: 1.7;
  margin-bottom: var(--space-lg);
}

.hero .cta-row { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }

.hero .cta-row .btn,
.section-contact .btn {
  display: inline-block;
  padding: 12px 24px;
  font-size: 0.9em;
  font-weight: 600;
  color: #ffffff;
  background: var(--pa-primary);
  border: none;
  border-radius: var(--pa-radius-control);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.hero .cta-row .btn:hover,
.section-contact .btn:hover { background: var(--pa-primary-hover); color: #ffffff; }

.hero .cta-row .meta {
  font-size: 0.85em;
  color: var(--pa-text-subtle);
  border-left: 1px solid var(--pa-border);
  padding-left: var(--space-md);
}

/* Full-width panel section */
.section-dark {
  background: var(--pa-surface-sunken);
  color: var(--pa-text);
  margin-left: calc(-1 * var(--space-xl));
  margin-right: calc(-1 * var(--space-xl));
  padding: var(--space-2xl) var(--space-xl);
  border-top: 1px solid var(--pa-border);
  border-bottom: 1px solid var(--pa-border);
}

.section-dark .section-inner { max-width: var(--content-max-width); margin: 0 auto; }

.section-dark .eyebrow {
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pa-accent);
  margin-bottom: var(--space-sm);
}

.section-dark h2 {
  font-family: var(--font-body);
  font-size: 1.8em;
  font-weight: 700;
  color: var(--pa-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.25;
}

.section-dark p { color: var(--pa-text-muted); max-width: 560px; }

/* Timeline */
.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 2px solid var(--pa-border);
  position: relative;
}

.timeline-item { position: relative; padding-top: var(--space-sm); }

.timeline-item::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  width: 12px;
  height: 12px;
  background: var(--pa-surface-raised);
  border: 2px solid var(--pa-accent);
  border-radius: 50%;
}

.timeline-item .year {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--pa-accent);
  margin-bottom: 4px;
}

.timeline-item h4 { font-size: 0.95em; font-weight: 600; color: var(--pa-text); margin-bottom: 4px; }
.timeline-item p { font-size: 0.82em; color: var(--pa-text-muted); line-height: 1.5; }

/* Services */
.section-services { padding: var(--space-2xl) 0; }
.section-services h2 { font-family: var(--font-body); font-size: 1.8em; font-weight: 700; color: var(--pa-primary); margin-bottom: var(--space-lg); }

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.service-card .number { font-size: 0.75em; font-weight: 600; color: var(--pa-accent); margin-bottom: var(--space-xs); }
.service-card h3 { font-family: var(--font-body); font-size: 1.1em; font-weight: 600; color: var(--pa-text); margin-bottom: var(--space-xs); }
.service-card p { font-size: 0.9em; color: var(--pa-text-muted); line-height: 1.6; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--pa-border);
  border-bottom: 1px solid var(--pa-border);
  margin: var(--space-lg) 0;
}

.stat { text-align: left; }
.stat .number { font-family: var(--font-body); font-size: 2.5em; font-weight: 700; color: var(--pa-primary); line-height: 1; margin-bottom: var(--space-xs); }
.stat p { font-size: 0.85em; color: var(--pa-text-muted); line-height: 1.5; }

/* Selected work */
.selected-work { padding: var(--space-2xl) 0; }
.selected-work h2 { font-family: var(--font-body); font-size: 1.8em; font-weight: 700; color: var(--pa-primary); margin-bottom: var(--space-lg); }

.work-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-top: 1px solid var(--pa-border);
  align-items: start;
}

.work-item:last-child { border-bottom: 1px solid var(--pa-border); }

.work-item .category {
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pa-accent);
  padding-top: 4px;
}

.work-item h3 { font-family: var(--font-body); font-size: 1.05em; font-weight: 600; color: var(--pa-text); margin-bottom: 4px; }
.work-item p { font-size: 0.9em; color: var(--pa-text-muted); line-height: 1.6; margin: 0; }

/* Publications */
.publications { padding: var(--space-2xl) 0; }
.publications h2 { font-family: var(--font-body); font-size: 1.8em; font-weight: 700; color: var(--pa-primary); margin-bottom: var(--space-lg); }

.pub-list { list-style: none; padding: 0; margin: 0; max-width: 640px; }
.pub-list li { padding: var(--space-sm) 0; border-bottom: 1px solid var(--pa-border); font-size: 0.9em; line-height: 1.6; }
.pub-list li:first-child { border-top: 1px solid var(--pa-border); }
.pub-list li strong { color: var(--pa-text); }

/* Contact CTA section */
.section-contact {
  background: var(--pa-primary);
  color: #ffffff;
  margin-left: calc(-1 * var(--space-xl));
  margin-right: calc(-1 * var(--space-xl));
  padding: var(--space-2xl) var(--space-xl);
  margin-top: var(--space-2xl);
}

.section-contact .section-inner { max-width: var(--content-max-width); margin: 0 auto; }

.section-contact h2 {
  font-family: var(--font-body);
  font-size: 2em;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: var(--space-sm);
}

.section-contact p { color: rgba(255, 255, 255, 0.85); max-width: 480px; margin-bottom: var(--space-lg); }

.section-contact .btn { background: #ffffff; color: var(--pa-primary); }
.section-contact .btn:hover { background: var(--pa-surface-sunken); color: var(--pa-primary); }

/* ==========================================================================
   8. NAVIGATION CARDS (sub-pages)
   ========================================================================== */

.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-sm);
  margin: var(--space-lg) 0;
}

.nav-card {
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-card);
  padding: var(--space-md);
  background: var(--pa-surface-raised);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.nav-card:hover {
  border-color: var(--pa-accent);
  box-shadow: 0 4px 16px rgba(31, 71, 136, 0.1);
  transform: translateY(-1px);
}

.nav-card h3 { font-size: 1em; font-weight: 600; color: var(--pa-primary); margin-bottom: 6px; }
.nav-card p { font-size: 0.85em; color: var(--pa-text-muted); margin: 0; line-height: 1.5; }

/* ==========================================================================
   9. RESPONSIVE
   ========================================================================== */

@media (max-width: 1024px) {
  section.content, .content { padding-left: var(--space-md); padding-right: var(--space-md); }
  .section-dark,
  .section-contact {
    margin-left: calc(-1 * var(--space-md));
    margin-right: calc(-1 * var(--space-md));
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

@media (max-width: 768px) {
  .app-nav { padding: 0 var(--space-sm); }
  .dark-mode-toggle { right: var(--space-sm); }

  .sidebar-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  section.content, .content {
    margin-left: 0;
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  .hero h1 { font-size: 2em !important; }

  .section-dark,
  .section-contact {
    margin-left: calc(-1 * var(--space-sm));
    margin-right: calc(-1 * var(--space-sm));
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  .timeline { grid-template-columns: 1fr 1fr; }
  .services-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .work-item { grid-template-columns: 1fr; gap: var(--space-xs); }
  .nav-cards { grid-template-columns: 1fr; }
}

/* ==========================================================================
   10. ACCESSIBILITY
   ========================================================================== */

a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--pa-accent);
  outline-offset: 2px;
  border-radius: var(--pa-radius-control);
}

.skip-link {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: -1;
  font-size: 0.85em;
  font-weight: 500;
  color: #ffffff;
  background: var(--pa-primary);
  padding: 8px 16px;
  border-radius: 0 0 var(--pa-radius-control) var(--pa-radius-control);
}

.skip-link:focus {
  position: fixed;
  top: 0;
  left: var(--space-sm);
  width: auto;
  height: auto;
  overflow: visible;
  z-index: 9999;
}

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

/* ==========================================================================
   11. DOCSIFY PLUGIN OVERRIDES
   ========================================================================== */

.docsify-copy-code-button {
  background: var(--pa-primary) !important;
  color: #ffffff !important;
  border-radius: var(--pa-radius-control);
  font-size: 0.75em;
}

.progress { background: var(--pa-accent) !important; }

/* Edit link */
.edit-link {
  text-align: right;
  margin-top: var(--space-2xl);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--pa-border);
}

.edit-link a {
  font-size: 0.78em;
  color: var(--pa-text-subtle);
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s, color 0.15s;
}

.edit-link a:hover { opacity: 1; color: var(--pa-primary); }
.edit-link svg { width: 13px; height: 13px; }

/* Page-heading sub-sidebar: visually subordinate to page links */
.sidebar-nav .app-sub-sidebar {
  list-style: none;
  padding: 2px 0 4px var(--space-sm);
  margin: 0 0 0 10px;
  border-left: 1px solid var(--pa-border);
}

.sidebar-nav .app-sub-sidebar li { margin: 0; }

.sidebar-nav .app-sub-sidebar a {
  display: block;
  padding: 3px 10px;
  font-size: 0.78em;
  color: var(--pa-text-subtle);
  border-radius: 3px;
  transition: color 0.15s;
}

.sidebar-nav .app-sub-sidebar a:hover { color: var(--pa-primary); }
.sidebar-nav .app-sub-sidebar a.active { color: var(--pa-primary); font-weight: 600; }

/* ==========================================================================
   12. CMS SEGMENT (copyright notice, sourced from pwa-refactor CMS)
   ========================================================================== */

.cms-segment {
  margin-top: var(--space-xl);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--pa-border);
  font-size: 0.78em;
  line-height: 1.6;
  color: var(--pa-text-subtle);
}

.cms-segment a { color: var(--pa-accent); }
.cms-segment a:hover { color: var(--pa-accent-hover); }
.cms-segment-loading { color: var(--pa-text-subtle); opacity: 0.5; }

/* ==========================================================================
   13. HOMEPAGE SECTION GRID (flex-grid widget cards)
   ========================================================================== */

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-md);
  margin: var(--space-lg) 0 var(--space-xl);
}

.home-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  background: var(--pa-surface-raised);
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-card);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

/* Accent bar on the leading edge, in the brand primary */
.home-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--pa-primary);
  opacity: 0.85;
  transition: width 0.2s;
}

.home-card:hover {
  border-color: var(--pa-accent);
  box-shadow: 0 6px 20px rgba(31, 71, 136, 0.12);
  transform: translateY(-2px);
}

.home-card:hover::before { width: 5px; }

.home-card-eyebrow {
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pa-accent);
  margin-bottom: var(--space-xs);
}

.home-card h3 {
  font-size: 1.15em;
  font-weight: 600;
  color: var(--pa-primary);
  margin: 0 0 var(--space-xs);
  line-height: 1.3;
}

.home-card p {
  font-size: 0.9em;
  color: var(--pa-text-muted);
  line-height: 1.6;
  margin: 0 0 var(--space-md);
  flex-grow: 1;
}

.home-card-cta {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--pa-accent);
  transition: color 0.15s;
}

.home-card:hover .home-card-cta { color: var(--pa-accent-hover); }

@media (max-width: 600px) {
  .home-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   14. MERMAID DIAGRAMS
   ========================================================================== */

.markdown-section .mermaid {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--pa-surface-raised);
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-card);
  text-align: center;
  overflow-x: auto;
}

.markdown-section .mermaid svg { max-width: 100%; height: auto; }

/* Figure caption that follows a diagram or widget */
.markdown-section .figure-caption {
  font-size: 0.82em;
  color: var(--pa-text-subtle);
  text-align: center;
  margin: calc(-1 * var(--space-xs)) 0 var(--space-md);
}

/* ==========================================================================
   15. IMAGE PLACEHOLDER (screenshots not yet added)
   ========================================================================== */

.markdown-section .image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 160px;
  margin: var(--space-sm) 0;
  padding: var(--space-md);
  background: var(--pa-surface-sunken);
  border: 1px dashed var(--pa-border-strong);
  border-radius: var(--pa-radius-card);
  text-align: center;
}

.image-placeholder-title {
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pa-text-muted);
}

.image-placeholder-alt {
  font-size: 0.82em;
  color: var(--pa-text-subtle);
  max-width: 60ch;
}

/* ==========================================================================
   16. BAR CHART FIGURE (pure CSS, theme-aware)
   ========================================================================== */

.markdown-section .bar-chart {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--pa-surface-raised);
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius-card);
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr 70px;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
}

.bar-label {
  font-size: 0.88em;
  font-weight: 600;
  color: var(--pa-text);
  line-height: 1.3;
}

.bar-label span {
  display: block;
  font-size: 0.85em;
  font-weight: 400;
  color: var(--pa-text-subtle);
}

.bar-track {
  height: 22px;
  background: var(--pa-surface-sunken);
  border-radius: var(--pa-radius-control);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--pa-primary);
  border-radius: var(--pa-radius-control);
}

.bar-value {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--pa-text);
  text-align: right;
}

@media (max-width: 600px) {
  .bar-row { grid-template-columns: 1fr 70px; }
  .bar-label { grid-column: 1 / -1; }
}
