/* ============================================
   Aegis Playground — Clean, modern dark theme
   ============================================ */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-panel: #1c2128;
  --bg-hover: #21262d;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;

  --risk-low: #3fb950;
  --risk-low-bg: rgba(63, 185, 80, 0.12);
  --risk-medium: #d29922;
  --risk-medium-bg: rgba(210, 153, 34, 0.12);
  --risk-high: #f85149;
  --risk-high-bg: rgba(248, 81, 73, 0.12);
  --risk-critical: #ff7b72;
  --risk-critical-bg: rgba(255, 123, 114, 0.15);

  --approval-auto: #3fb950;
  --approval-approve: #d29922;
  --approval-block: #f85149;

  --radius: 8px;
}

/* Global keyboard focus indicator */
:focus-visible {
  outline: 2px solid var(--accent, #58a6ff);
  outline-offset: 2px;
}

/* Smooth theme transition */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* CodeMirror theme transition */
.theme-transition .CodeMirror,
.theme-transition .CodeMirror-gutters {
  transition: background-color 0.3s ease, color 0.3s ease !important;
}

/* Theme switch flash overlay */
.theme-flash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
  will-change: opacity;
}

/* Respect system dark/light when no explicit theme is set */
@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    color-scheme: light;
  }
}

/* Light theme overrides */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-panel: #ffffff;
  --bg-hover: #f0f2f5;
  --border: #d0d7de;
  --text-primary: #1f2328;
  --text-secondary: #636c76;
  --text-muted: #8c959f;
  --accent: #0969da;
  --accent-hover: #0550ae;

  --risk-low: #1a7f37;
  --risk-low-bg: rgba(26, 127, 55, 0.1);
  --risk-medium: #9a6700;
  --risk-medium-bg: rgba(154, 103, 0, 0.1);
  --risk-high: #cf222e;
  --risk-high-bg: rgba(207, 34, 46, 0.1);
  --risk-critical: #a40e26;
  --risk-critical-bg: rgba(164, 14, 38, 0.12);

  --approval-auto: #1a7f37;
  --approval-approve: #9a6700;
  --approval-block: #cf222e;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(31, 35, 40, 0.12), 0 0 1px rgba(31, 35, 40, 0.08);
}

/* Light theme before/after */
[data-theme="light"] .ba-before { background: rgba(207, 34, 46, 0.06); border-color: rgba(207, 34, 46, 0.2); }
[data-theme="light"] .ba-before .ba-label { color: #cf222e; }
[data-theme="light"] .ba-after { background: rgba(26, 127, 55, 0.06); border-color: rgba(26, 127, 55, 0.2); }
[data-theme="light"] .ba-after .ba-label { color: #1a7f37; }

/* Light theme decision matrix */
[data-theme="light"] .dm-low .dm-risk { color: #1a7f37; }
[data-theme="light"] .dm-medium .dm-risk { color: #9a6700; }
[data-theme="light"] .dm-high .dm-risk { color: #bc4c00; }
[data-theme="light"] .dm-critical .dm-risk { color: #cf222e; }
[data-theme="light"] .dm-header { background: rgba(175, 184, 193, 0.12); }

/* Light theme panel refinements */
[data-theme="light"] .panel {
  box-shadow: 0 1px 2px rgba(31, 35, 40, 0.06);
}

[data-theme="light"] .result-card {
  box-shadow: 0 1px 2px rgba(31, 35, 40, 0.04);
}

/* Light theme: toast shadow lighter */
[data-theme="light"] .toast {
  box-shadow: 0 2px 8px rgba(31, 35, 40, 0.1);
}

/* Light theme: eval-timeline code bg */
[data-theme="light"] .tl-step code {
  color: #0550ae;
  background: rgba(9, 105, 218, 0.06);
}

/* Light theme: arch-flow pulse color */
[data-theme="light"] .arch-flow.animate-flow .arch-arrow-line::before {
  background: #0969da;
  box-shadow: 0 0 6px #0969da;
}

/* Light theme: block particle visibility */
[data-theme="light"] .block-particle {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Light theme: scroll-top button */
[data-theme="light"] .scroll-top-btn {
  box-shadow: 0 1px 4px rgba(31, 35, 40, 0.15);
}

/* High-contrast theme — WCAG AAA-ready */
[data-theme="high-contrast"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-panel: #0a0a0a;
  --bg-hover: #1a1a1a;
  --border: #666666;
  --text-primary: #ffffff;
  --text-secondary: #d0d0d0;
  --text-muted: #a0a0a0;
  --accent: #6cb6ff;
  --accent-hover: #9cd4ff;

  --risk-low: #56d364;
  --risk-low-bg: rgba(86, 211, 100, 0.2);
  --risk-medium: #f0c000;
  --risk-medium-bg: rgba(240, 192, 0, 0.2);
  --risk-high: #ff6b6b;
  --risk-high-bg: rgba(255, 107, 107, 0.2);
  --risk-critical: #ff4444;
  --risk-critical-bg: rgba(255, 68, 68, 0.25);

  --approval-auto: #56d364;
  --approval-approve: #f0c000;
  --approval-block: #ff6b6b;
}

/* Theme icon visibility */
.theme-icon-light,
.theme-icon-hc { display: none; }
.theme-icon-dark { display: inline; }

[data-theme="light"] .theme-icon-dark,
[data-theme="light"] .theme-icon-hc { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

[data-theme="high-contrast"] .theme-icon-dark,
[data-theme="high-contrast"] .theme-icon-light { display: none; }
[data-theme="high-contrast"] .theme-icon-hc { display: inline; }

/* High-contrast focus and border enhancements */
[data-theme="high-contrast"] :focus-visible {
  outline: 3px solid #6cb6ff;
  outline-offset: 2px;
}

[data-theme="high-contrast"] .panel {
  border-width: 2px;
}

[data-theme="high-contrast"] .result-card {
  border-width: 2px;
}

[data-theme="high-contrast"] button:hover {
  outline: 1px solid #6cb6ff;
}

[data-theme="high-contrast"] .decision-matrix {
  border-width: 2px;
}
[data-theme="high-contrast"] .dm-row { border-color: #666; }
[data-theme="high-contrast"] .dm-low .dm-risk { color: #56d364; }
[data-theme="high-contrast"] .dm-medium .dm-risk { color: #f0c000; }
[data-theme="high-contrast"] .dm-high .dm-risk { color: #ff6b6b; }
[data-theme="high-contrast"] .dm-critical .dm-risk { color: #ff4444; }

[data-theme="high-contrast"] .cm-error-widget { border-left-width: 4px; }
[data-theme="high-contrast"] .cm-warn-widget { border-left-width: 4px; }
[data-theme="high-contrast"] .shortcut-row kbd {
  border-width: 2px;
  font-weight: 600;
}

[data-theme="high-contrast"] .tl-step {
  border-width: 2px;
}

[data-theme="high-contrast"] .tl-num {
  background: #6cb6ff;
}

[data-theme="high-contrast"] .trust-badge {
  border-width: 2px;
}

[data-theme="high-contrast"] .docker-btn {
  border-color: #6cb6ff;
  color: #6cb6ff;
}

[data-theme="high-contrast"] .fix-all-btn {
  border-width: 2px;
}

[data-theme="high-contrast"] .scroll-top-btn {
  border-width: 2px;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button, a, .preset-btn, .action-btn, .audit-filter { touch-action: manipulation; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Custom scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg-primary); }

/* ---- Loading Overlay ---- */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.4s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-content {
  text-align: center;
  max-width: 400px;
}

.loader-content h2 {
  margin: 16px 0 8px;
  font-size: 1.3rem;
}

.loader-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.loading-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 12px;
  transition: opacity 0.3s ease;
  font-style: italic;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #79c0ff, var(--accent));
  background-size: 200% 100%;
  width: 0%;
  transition: width 0.5s ease;
  animation: progressShimmer 1.5s linear infinite;
  will-change: width, background-position;
}

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

/* ---- Header ---- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.header-left h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.badge {
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--accent);
  color: #000;
  padding: 2px 8px;
  border-radius: 12px;
  vertical-align: middle;
  margin-left: 4px;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 2px;
}

.social-proof {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.proof-item {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.proof-sep {
  font-size: 0.5rem;
  color: var(--text-muted);
}

.pip-btn {
  font-family: monospace;
  font-size: 0.75rem;
  padding: 4px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.pip-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pyproject-btn {
  border-color: rgba(46, 160, 67, 0.4);
  color: #2ea043;
}
.pyproject-btn:hover {
  border-color: #2ea043;
  color: #2ea043;
  background: rgba(46, 160, 67, 0.08);
}
.docker-btn {
  border-color: rgba(38, 128, 235, 0.4);
  color: #2680eb;
}
.docker-btn:hover {
  border-color: #2680eb;
  color: #2680eb;
  background: rgba(38, 128, 235, 0.08);
}

.header-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.gh-link, .pypi-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
}

.gh-link:hover, .pypi-link:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.15s, transform 0.3s ease;
  position: relative;
}
.theme-toggle:hover {
  border-color: var(--text-secondary);
}
.theme-toggle[data-next-theme]:hover::after {
  content: attr(data-next-theme);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.7rem;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

.theme-toggle:active {
  transform: rotate(180deg) scale(0.9);
}

/* ---- Integrations Bar ---- */
.integrations-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.integrations-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 4px;
}

.integration-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  background: var(--bg-primary);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

a.integration-badge:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

a.integration-badge:active {
  transform: scale(0.96);
}

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-auto .stat-value { color: var(--risk-low); }
.stat-approve .stat-value { color: var(--risk-medium); }
.stat-block .stat-value { color: var(--risk-high); }

.stat-pop {
  animation: statPop 0.3s ease-out;
}
.stat-auto .stat-value.stat-pop { text-shadow: 0 0 8px var(--approval-auto); }
.stat-approve .stat-value.stat-pop { text-shadow: 0 0 8px var(--approval-approve); }
.stat-block .stat-value.stat-pop { text-shadow: 0 0 8px var(--approval-block); }

@keyframes statPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.stat-milestone {
  animation: milestoneGlow 1.5s ease-out;
}

@keyframes milestoneGlow {
  0% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.4); }
  30% { box-shadow: 0 0 12px 4px rgba(88, 166, 255, 0.3); }
  100% { box-shadow: none; }
}

/* ---- How It Works ---- */
.how-it-works {
  padding: 20px 24px 4px;
  max-width: 1600px;
  margin: 0 auto;
}

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.step {
  flex: 1;
  max-width: 280px;
  text-align: center;
  padding: 20px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}

.step-number {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.step h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.step p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.step-metrics {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: center;
}

.step-metric {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
}

.step-time {
  background: rgba(63, 185, 80, 0.1);
  color: #3fb950;
  border: 1px dashed rgba(63, 185, 80, 0.3);
}
[data-theme="light"] .step-time {
  color: #1a7f37;
  background: rgba(26, 127, 55, 0.08);
  border-color: rgba(26, 127, 55, 0.25);
}

.step-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 0 12px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .steps {
    flex-direction: column;
    gap: 8px;
  }
  .step-arrow {
    transform: rotate(90deg);
    padding: 4px 0;
  }
  .step {
    max-width: 100%;
  }
}

/* ---- Main Layout ---- */
main {
  padding: 16px 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.top-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.bottom-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---- Panels ---- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.panel-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---- Policy Editor ---- */
.preset-buttons {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.preset-btn {
  font-size: 0.75rem;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.preset-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  animation: presetActivate 0.3s ease;
}

@keyframes presetActivate {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.preset-btn.industry {
  border-style: dashed;
}

.preset-btn.industry.active {
  border-style: solid;
}

.preset-divider {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 0 2px;
  user-select: none;
}

.preset-buttons {
  flex-wrap: wrap;
  row-gap: 4px;
}

.editor-wrapper {
  height: 380px;
}

.editor-wrapper .CodeMirror {
  height: 100%;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.editor-wrapper .CodeMirror-focused {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.editor-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 3px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  font-style: italic;
}

.CodeMirror-activeline-background {
  background: rgba(88, 166, 255, 0.04);
}

.cm-error-line {
  background: rgba(248, 81, 73, 0.15) !important;
  border-bottom: 2px wavy var(--risk-high);
}

.cm-error-widget {
  font-size: 0.75rem;
  color: #f85149;
  background: rgba(248, 81, 73, 0.08);
  border-left: 3px solid #f85149;
  padding: 3px 8px;
  margin: 2px 0 2px 20px;
  border-radius: 0 4px 4px 0;
  font-family: monospace;
  animation: widgetFadeIn 0.2s ease;
}
.cm-error-widget::before { content: "\u274C "; }

@keyframes widgetFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.cm-warn-widget {
  font-size: 0.75rem;
  color: #d29922;
  background: rgba(210, 153, 34, 0.08);
  border-left: 3px solid #d29922;
  padding: 3px 8px;
  margin: 2px 0 2px 20px;
  border-radius: 0 4px 4px 0;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: widgetFadeIn 0.2s ease;
}
.warn-text { flex: 1; }
.warn-fix-btn {
  font-size: 0.68rem;
  background: rgba(210, 153, 34, 0.18);
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: 3px;
  padding: 1px 6px;
  cursor: pointer;
  white-space: nowrap;
}
.warn-fix-btn:hover { background: rgba(210, 153, 34, 0.3); }
.warn-dismiss-btn {
  font-size: 0.85rem;
  background: none;
  color: #d29922;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.warn-dismiss-btn:hover { opacity: 1; }

/* Info-level widget (softer suggestions) */
.cm-info-widget {
  font-size: 0.75rem;
  color: var(--accent, #58a6ff);
  background: rgba(88, 166, 255, 0.06);
  border-left: 3px solid var(--accent, #58a6ff);
  padding: 3px 8px;
  margin: 2px 0 2px 20px;
  border-radius: 0 4px 4px 0;
  font-family: monospace;
  animation: widgetFadeIn 0.2s ease;
}
.cm-info-widget::before { content: "\u2139\uFE0F "; }

/* "Fix All" button shown in the warning status area */
.fix-all-btn {
  font-size: 0.68rem;
  background: rgba(210, 153, 34, 0.18);
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: 3px;
  padding: 1px 8px;
  cursor: pointer;
  margin-left: 6px;
  white-space: nowrap;
  transition: background 0.15s;
}
.fix-all-btn:hover { background: rgba(210, 153, 34, 0.35); }

.rule-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 2px 6px;
  white-space: nowrap;
}

.validation-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(63, 185, 80, 0.12);
  color: #3fb950;
  margin-left: auto;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.validation-status.status-error {
  background: rgba(248, 81, 73, 0.12);
  color: #f85149;
}

.validation-status.status-checking {
  background: rgba(210, 153, 34, 0.12);
  color: #d29922;
}

.validation-status.status-warn {
  background: rgba(210, 153, 34, 0.12);
  color: #d29922;
}

.editor-error {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-family: 'SF Mono', Menlo, monospace;
  color: var(--risk-high);
  background: var(--risk-high-bg);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.error-fix-btn {
  flex-shrink: 0;
  background: var(--risk-high);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.error-fix-btn:hover {
  opacity: 0.85;
}

/* ---- Action Panel ---- */
.action-content {
  padding: 16px;
  overflow-y: auto;
  max-height: 420px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.85rem;
  position: relative;
  overflow: hidden;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.action-btn.risk-low:hover { border-color: var(--risk-low); background: var(--risk-low-bg); }
.action-btn.risk-medium:hover { border-color: var(--risk-medium); background: var(--risk-medium-bg); }
.action-btn.risk-high:hover { border-color: var(--risk-high); background: var(--risk-high-bg); }
.action-btn.risk-critical:hover { border-color: var(--risk-critical); background: var(--risk-critical-bg); }

.btn-ripple {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%) scale(0);
  animation: rippleExpand 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes rippleExpand {
  to { transform: translate(-50%, -50%) scale(30); opacity: 0; }
}

.action-btn.action-running {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.3);
  animation: actionPulse 0.6s ease-in-out infinite;
}

@keyframes actionPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.action-icon {
  font-size: 1.4rem;
}

.action-label {
  font-weight: 600;
  font-size: 0.8rem;
}

.action-risk {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

/* ---- Custom Action Form ---- */
kbd {
  font-size: 0.65rem;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-family: 'SF Mono', Menlo, monospace;
  margin-left: 6px;
  vertical-align: middle;
}

.custom-action {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.custom-action h3 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.form-row label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 60px;
  flex-shrink: 0;
}

.form-row input {
  flex: 1;
  padding: 5px 8px;
  font-size: 0.8rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  font-family: 'SF Mono', Menlo, monospace;
}

.form-row input:focus {
  border-color: var(--accent);
}

.run-btn {
  width: 100%;
  padding: 6px;
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.run-btn:hover {
  background: var(--accent-hover);
}

.run-all-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.run-all-btn:hover {
  background: rgba(88, 166, 255, 0.1);
}
.run-all-btn:not(:disabled) {
  animation: idleAttention 3s ease-in-out 5s infinite;
}
.run-all-btn:hover { animation: none; }
.run-all-btn:disabled {
  cursor: wait;
  background: linear-gradient(90deg, transparent 0%, rgba(88, 166, 255, 0.1) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: runAllShimmer 1.5s ease infinite;
}
@keyframes runAllShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes idleAttention {
  0%, 85% { box-shadow: none; }
  90% { box-shadow: 0 0 8px rgba(88, 166, 255, 0.4); }
  100% { box-shadow: none; }
}

/* ---- Result Panel ---- */
.result-content {
  padding: 16px;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 40px 20px;
}

.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  animation: cardSlideIn 0.25s ease-out;
  contain: layout style;
}

.result-card.result-allowed {
  border-left: 3px solid var(--risk-low);
  animation: slideInGreen 0.25s ease;
}

@keyframes slideInGreen {
  from { opacity: 0; transform: translateX(8px); border-left-color: transparent; }
  to { opacity: 1; transform: translateX(0); }
}

.result-card.result-blocked {
  border-left: 3px solid var(--risk-high);
  animation: slideInRed 0.25s ease, pulseRed 0.5s ease;
}

@keyframes slideInRed {
  from { opacity: 0; transform: translateX(-8px); border-left-color: transparent; }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulseRed {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 12px rgba(248, 81, 73, 0.3); }
}

/* ---- Blocked Effect: CSS-only red dot particle burst ---- */
.result-card.blocked-effect {
  position: relative;
  overflow: visible;
  animation: blockedPulse 0.6s ease-out;
}

@keyframes blockedPulse {
  0% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.5); }
  40% { box-shadow: 0 0 12px 4px rgba(248, 81, 73, 0.3); }
  100% { box-shadow: none; }
}

.result-card.blocked-effect::before,
.result-card.blocked-effect::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 10%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--risk-high);
  pointer-events: none;
  opacity: 0;
}

.result-card.blocked-effect::before {
  animation: dotScatter1 0.6s ease-out forwards;
  box-shadow:
    18px -4px 0 0 var(--risk-high),
    40px -12px 0 -1px var(--risk-critical);
}

.result-card.blocked-effect::after {
  left: 60%;
  animation: dotScatter2 0.6s 0.05s ease-out forwards;
  box-shadow:
    -10px -8px 0 0 var(--risk-high),
    22px -6px 0 -1px var(--risk-critical);
}

@keyframes dotScatter1 {
  0% {
    opacity: 0.9;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-20px, -35px) scale(0.3);
  }
}

@keyframes dotScatter2 {
  0% {
    opacity: 0.9;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(15px, -30px) scale(0.3);
  }
}

/* Screen shake on block */
.shake {
  animation: panelShake 0.3s ease-out;
}

@keyframes panelShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.result-action-type {
  font-weight: 700;
  font-size: 0.95rem;
}

.result-target {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.result-badges {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.risk-badge, .approval-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.risk-badge.low { background: var(--risk-low-bg); color: var(--risk-low); }
.risk-badge.medium { background: var(--risk-medium-bg); color: var(--risk-medium); }
.risk-badge.high { background: var(--risk-high-bg); color: var(--risk-high); }
.risk-badge.critical { background: var(--risk-critical-bg); color: var(--risk-critical); }

.approval-badge.auto { background: rgba(63, 185, 80, 0.12); color: var(--approval-auto); }
.approval-badge.approve { background: rgba(210, 153, 34, 0.12); color: var(--approval-approve); }
.approval-badge.block { background: rgba(248, 81, 73, 0.12); color: var(--approval-block); }

.result-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.result-detail {
  font-size: 0.78rem;
}

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

.result-detail .value {
  color: var(--text-primary);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.75rem;
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.result-allowed {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.result-copy-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .result-copy-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .result-copy-group::-webkit-scrollbar { display: none; }
}

.copy-code-btn {
  font-size: 0.68rem;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.copy-code-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.copy-code-btn:active {
  transform: scale(0.95);
  background: rgba(88, 166, 255, 0.08);
}

.copy-success {
  border-color: var(--approval-auto) !important;
  color: var(--approval-auto) !important;
}

.result-allowed.yes { color: var(--risk-low); }
.result-allowed.no { color: var(--risk-high); }

/* ---- Audit Panel ---- */
.audit-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.clear-btn {
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.clear-btn:hover {
  border-color: var(--risk-high);
  color: var(--risk-high);
}

.audit-content {
  padding: 8px 16px;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.75rem;
}

.audit-filters {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

.audit-filter {
  font-size: 0.7rem;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.audit-filter:hover {
  border-color: var(--text-muted);
}

.audit-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.audit-filter.filter-auto.active {
  background: var(--approval-auto);
  border-color: var(--approval-auto);
}

.audit-filter.filter-approve.active {
  background: var(--approval-approve);
  border-color: var(--approval-approve);
}

.audit-filter.filter-block.active {
  background: var(--approval-block);
  border-color: var(--approval-block);
}

.audit-search {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.7rem;
  width: 120px;
  outline: none;
  transition: border-color 0.2s, width 0.2s;
}

.audit-search:focus {
  border-color: var(--accent);
  width: 160px;
}

.audit-search.search-active {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

.audit-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  contain: layout style;
}

/* CSS-only audit filtering via container data-filter attribute */
[data-filter="auto"] .audit-row:not([data-approval="auto"]),
[data-filter="approve"] .audit-row:not([data-approval="approve"]),
[data-filter="block"] .audit-row:not([data-approval="block"]) { display: none; }
.audit-row.search-hidden { display: none; }

.audit-time {
  color: var(--text-muted);
  flex-shrink: 0;
  width: 70px;
}

.audit-type {
  font-weight: 600;
  width: 100px;
  flex-shrink: 0;
}

.audit-risk {
  width: 65px;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.7rem;
}

.audit-risk.low { color: var(--risk-low); }
.audit-risk.medium { color: var(--risk-medium); }
.audit-risk.high { color: var(--risk-high); }
.audit-risk.critical { color: var(--risk-critical); }

.audit-decision {
  width: 65px;
  flex-shrink: 0;
}

.audit-decision.auto { color: var(--approval-auto); }
.audit-decision.approve { color: var(--approval-approve); }
.audit-decision.block { color: var(--approval-block); }

.audit-rule {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Eval Timeline ---- */
.eval-timeline {
  max-width: 700px;
  margin: 24px auto 0;
  text-align: center;
}

.timeline-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.tl-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}

.tl-step code {
  font-size: 0.72rem;
  color: var(--accent, #58a6ff);
  background: rgba(88, 166, 255, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

.tl-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #58a6ff);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.tl-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .timeline-steps {
    flex-direction: column;
    gap: 4px;
  }
  .tl-arrow {
    transform: rotate(90deg);
  }
}

/* ---- Architecture Flow Diagram ---- */
.arch-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 56px auto 0;
  max-width: 780px;
  flex-wrap: wrap;
}

.arch-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  min-width: 140px;
}

.arch-node .arch-icon { font-size: 1.8rem; }
.arch-node .arch-label { font-weight: 700; font-size: 0.95rem; color: var(--text-primary); margin-top: 4px; }
.arch-node .arch-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.arch-node[data-tip] { cursor: help; position: relative; }
.arch-node[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  line-height: 1.4;
  max-width: 220px;
  white-space: normal;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.arch-engine { border-color: var(--accent); background: rgba(88, 166, 255, 0.06); }
.arch-summary {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 10px;
  font-style: italic;
}

/* Stagger animation for arch flow items */
.arch-flow.animate-flow > * {
  opacity: 0;
  transform: translateX(-20px);
  animation: archFlowIn 0.4s ease-out forwards;
}

.arch-flow.animate-flow > *:nth-child(1) { animation-delay: 0s; }
.arch-flow.animate-flow > *:nth-child(2) { animation-delay: 0.15s; }
.arch-flow.animate-flow > *:nth-child(3) { animation-delay: 0.3s; }
.arch-flow.animate-flow > *:nth-child(4) { animation-delay: 0.45s; }
.arch-flow.animate-flow > *:nth-child(5) { animation-delay: 0.6s; }

@keyframes archFlowIn {
  to { opacity: 1; transform: translateX(0); }
}

.arch-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
}

.arch-arrow-line {
  display: block;
  width: 48px;
  height: 2px;
  background: var(--text-muted);
  position: relative;
  overflow: hidden;
}

/* Animated data pulse traveling along the arrow */
.arch-flow.animate-flow .arch-arrow-line::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #58a6ff);
  box-shadow: 0 0 6px var(--accent, #58a6ff);
  animation: archPulse 1.8s 0.8s ease-in-out infinite;
}

@keyframes archPulse {
  0%   { left: -6px; opacity: 0; }
  10%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { left: calc(100% + 6px); opacity: 0; }
}

.arch-arrow-line::after {
  content: "";
  position: absolute;
  right: 0;
  top: -4px;
  border: 5px solid transparent;
  border-left-color: var(--text-muted);
}

.arch-arrow-text { font-size: 0.65rem; color: var(--text-muted); margin-top: 4px; }

/* Stagger second arrow pulse */
.arch-flow.animate-flow > :nth-child(4) .arch-arrow-line::before {
  animation-delay: 1.6s;
}

.arch-decisions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.arch-decision {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 8px;
  text-align: center;
}

.arch-auto { background: rgba(63, 185, 80, 0.12); color: #3fb950; }
.arch-approve { background: rgba(210, 153, 34, 0.12); color: #d29922; }
.arch-block { background: rgba(248, 81, 73, 0.12); color: #f85149; }

/* ---- Decision Matrix ---- */
.decision-matrix {
  max-width: 520px;
  margin: 24px auto 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  font-size: 0.82rem;
}
.dm-row {
  display: grid;
  grid-template-columns: 100px 1fr 140px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.dm-row:last-child { border-bottom: none; }
.decision-matrix.animate-flow .dm-row:not(.dm-header) {
  opacity: 0;
  transform: translateX(-8px);
  animation: dmRowIn 0.3s ease forwards;
}
.dm-low { animation-delay: 0.05s; }
.dm-medium { animation-delay: 0.1s; }
.dm-high { animation-delay: 0.15s; }
.dm-critical { animation-delay: 0.2s; }
@keyframes dmRowIn {
  to { opacity: 1; transform: translateX(0); }
}
.dm-header {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dm-risk { font-weight: 700; font-size: 0.72rem; letter-spacing: 0.04em; }
.dm-low .dm-risk { color: #3fb950; }
.dm-medium .dm-risk { color: #d29922; }
.dm-high .dm-risk { color: #f0883e; }
.dm-critical .dm-risk { color: #f85149; }
.dm-decision { font-size: 0.78rem; }

/* ---- Quickstart Code Snippet ---- */
.trust-signals {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.trust-badge {
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-weight: 500;
}

.framework-compat {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
}

.compat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.compat-item {
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 2px 8px;
  border: 1px dashed var(--border);
  border-radius: 4px;
}

.quickstart-code {
  margin-top: 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.code-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.code-tab {
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.code-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.code-tab.active {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.code-panel {
  display: none;
  padding: 16px 20px;
}

.code-panel.active {
  display: block;
  animation: codePanelIn 0.2s ease;
}

@keyframes codePanelIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.code-panel pre {
  margin: 0;
  overflow-x: auto;
}

.code-panel code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.code-panel code .k { color: #ff7b72; }
.code-panel code .s { color: #a5d6ff; }
.code-panel code .c { color: var(--text-muted); }
.code-panel code .g { color: var(--approval-auto); }
.code-panel code .y { color: var(--approval-approve); }
.code-panel code .r { color: var(--approval-block); }

/* Light theme syntax colors */
[data-theme="light"] .code-panel code .k { color: #cf222e; }
[data-theme="light"] .code-panel code .s { color: #0550ae; }

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
}

.code-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Comparison Section ---- */
.comparison-section {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 24px 16px;
}

.comparison-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 0;
}

.comp-tab {
  flex: 1;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.comp-tab:first-child {
  border-radius: var(--radius) 0 0 0;
}

.comp-tab:last-child {
  border-radius: 0 var(--radius) 0 0;
  border-left: none;
}

.comp-tab.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  border-bottom-color: transparent;
}

.comp-code {
  margin: 0;
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-primary);
}

.comp-code.hidden {
  display: none;
}

/* Adoption Speed Row */
.adoption-speed {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.adoption-item {
  text-align: center;
}

.reveal-visible .adoption-item {
  animation: fadeSlideUp 0.4s ease both;
}
.reveal-visible .adoption-item:nth-child(1) { animation-delay: 0s; }
.reveal-visible .adoption-item:nth-child(2) { animation-delay: 0.1s; }
.reveal-visible .adoption-item:nth-child(3) { animation-delay: 0.2s; }
.reveal-visible .adoption-item:nth-child(4) { animation-delay: 0.3s; }

.adoption-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.adoption-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.key-benefits {
  list-style: none;
  max-width: 480px;
  margin: 24px auto 0;
  text-align: left;
}

.key-benefits li {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.key-benefits li:last-child { border-bottom: none; }

.key-benefits strong { color: var(--text-primary); }

/* ---- Try It CTA ---- */
.try-it-cta {
  margin-top: 32px;
  text-align: center;
}

.try-it-cta p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.try-it-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.try-it-btn:hover {
  background: #1f6feb;
  transform: translateY(-1px);
}

.try-it-btn:active {
  transform: scale(0.97);
}

/* ---- Use Cases Section ---- */
.usecases-section {
  text-align: center;
  padding: 32px 24px;
  margin: 16px auto;
  max-width: 1200px;
}

.usecases-section h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.usecases-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.usecases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.usecase-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
  font-family: inherit;
}

.usecase-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.usecase-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.usecase-card h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.usecase-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.usecase-tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

/* ---- CTA Section ---- */
.cta-section {
  text-align: center;
  padding: 40px 24px;
  margin: 16px auto;
  max-width: 600px;
}

.cta-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.cta-stats #action-counter {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
}

.cta-section h2 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.cta-section p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.cta-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}

.cta-primary {
  background: var(--accent);
  color: #000;
  border: 1px solid var(--accent);
}

.cta-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.cta-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.cta-secondary:hover {
  border-color: var(--text-secondary);
}

/* ---- Footer ---- */
footer {
  text-align: center;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  content-visibility: auto;
  contain-intrinsic-size: auto 80px;
}

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

footer code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.footer-shortcuts {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

.shortcut {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.shortcut kbd {
  font-size: 0.7rem;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: inherit;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 6px;
}

.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-icon {
  font-size: 0.85rem;
}

/* ---- Decision-type result styling ---- */
.result-card.result-auto {
  border-left: 3px solid var(--approval-auto);
}

.result-card.result-approve {
  border-left: 3px solid var(--approval-approve);
}

.result-card.result-block {
  border-left: 3px solid var(--approval-block);
}

/* Entrance animation — all cards slide in */
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Auto-approved flash — brief green glow */
.result-card.flash-auto {
  animation: cardSlideIn 0.25s ease-out, glowGreen 0.6s ease-out;
}

@keyframes glowGreen {
  0%   { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4); }
  50%  { box-shadow: 0 0 12px 2px rgba(63, 185, 80, 0.25); }
  100% { box-shadow: none; }
}

/* Needs-approval flash — amber pulse */
.result-card.flash-approve {
  animation: cardSlideIn 0.25s ease-out, glowAmber 0.6s ease-out;
}

@keyframes glowAmber {
  0%   { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.4); }
  50%  { box-shadow: 0 0 12px 2px rgba(210, 153, 34, 0.25); }
  100% { box-shadow: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .result-card,
  .result-card.flash-auto,
  .result-card.flash-approve {
    animation: none;
  }
}

/* ---- Auto-Approve Checkmarks ---- */
.auto-checkmark {
  position: fixed;
  font-size: 1rem;
  font-weight: 700;
  color: #3fb950;
  pointer-events: none;
  z-index: 1000;
  animation: checkmarkBurst 0.7s ease-out forwards;
}

@keyframes checkmarkBurst {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.4); }
}

/* ---- Approve Pulse Ring ---- */
.approve-pulse-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(210, 153, 34, 0.5);
  border-radius: inherit;
  pointer-events: none;
  animation: pulseRingExpand 0.6s ease-out forwards;
}

@keyframes pulseRingExpand {
  0%   { transform: scale(0.98); opacity: 0.8; }
  100% { transform: scale(1.04); opacity: 0; }
}

/* ---- Block Particles ---- */
.block-particle {
  position: fixed;
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 1000;
  animation: particleFly 0.8s ease-out forwards;
}

@keyframes particleFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  60% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.3) rotate(var(--rot, 180deg));
  }
}

/* ---- Export Menu ---- */
.export-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.export-header {
  padding: 6px 20px;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.export-option {
  display: block;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.export-option:hover {
  background: var(--bg-hover);
}

.export-option + .export-option {
  border-top: 1px solid var(--border);
}

/* ---- Audit Chart ---- */
.audit-chart {
  flex: 1;
  min-width: 120px;
  max-width: 220px;
}

.chart-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg-secondary);
  margin-bottom: 4px;
}

.chart-seg {
  transition: width 0.3s ease;
}

.chart-auto { background: var(--approval-auto); }
.chart-approve { background: var(--approval-approve); }
.chart-block { background: var(--approval-block); }

.chart-legend {
  display: flex;
  gap: 8px;
  font-size: 0.65rem;
}

.legend-auto { color: var(--approval-auto); }
.legend-approve { color: var(--approval-approve); }
.legend-block { color: var(--approval-block); }

/* ---- Guided Tour ---- */
.tour-highlight {
  position: relative;
  z-index: 1001;
  box-shadow: 0 0 0 4px var(--accent), 0 0 24px rgba(88, 166, 255, 0.3);
  border-radius: var(--radius);
  transition: box-shadow 0.3s ease;
}

.tour-tooltip {
  position: fixed;
  z-index: 1002;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 16px 20px;
  max-width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: tourFadeIn 0.3s ease;
}

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

.tour-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.tour-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.tour-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.tour-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
}

.tour-skip:hover {
  color: var(--text-secondary);
}

.tour-next {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.tour-next:hover {
  opacity: 0.85;
}

.tour-progress {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
}

@media (max-width: 640px) {
  .tour-tooltip {
    position: fixed !important;
    bottom: 20px !important;
    left: 16px !important;
    right: 16px !important;
    top: auto !important;
    transform: none !important;
    max-width: none;
  }
}

/* ---- Share Modal ---- */
.share-modal-inner {
  max-width: 480px;
}

.share-url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.share-url-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.8rem;
  font-family: monospace;
  outline: none;
}

.share-url-input:focus {
  border-color: var(--accent);
}

.share-links {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.share-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.15s;
}

.share-link:hover {
  opacity: 0.85;
}

.share-twitter {
  background: #1d9bf0;
  color: #fff;
}

.share-linkedin {
  background: #0a66c2;
  color: #fff;
}

.share-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---- Lazy Reveal Animations ---- */
.reveal-hidden {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger child cards */
.reveal-visible .step-card,
.reveal-visible .usecase-card {
  animation: fadeSlideUp 0.4s ease both;
}

.reveal-visible .step-card:nth-child(1),
.reveal-visible .usecase-card:nth-child(1) { animation-delay: 0s; }
.reveal-visible .step-card:nth-child(2),
.reveal-visible .usecase-card:nth-child(2) { animation-delay: 0.08s; }
.reveal-visible .step-card:nth-child(3),
.reveal-visible .usecase-card:nth-child(3) { animation-delay: 0.16s; }
.reveal-visible .usecase-card:nth-child(4) { animation-delay: 0.24s; }
.reveal-visible .usecase-card:nth-child(5) { animation-delay: 0.32s; }
.reveal-visible .usecase-card:nth-child(6) { animation-delay: 0.4s; }
.reveal-visible .usecase-card:nth-child(7) { animation-delay: 0.48s; }
.reveal-visible .usecase-card:nth-child(8) { animation-delay: 0.56s; }
.reveal-visible .usecase-card:nth-child(9) { animation-delay: 0.64s; }
.reveal-visible .usecase-card:nth-child(10) { animation-delay: 0.72s; }

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .reveal-hidden {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .reveal-visible .step-card,
  .reveal-visible .usecase-card {
    animation: none;
  }
  .arch-flow.animate-flow .arch-arrow-line::before {
    animation: none;
    display: none;
  }
}

/* ---- Keyboard Shortcut Overlay ---- */
.shortcut-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.shortcut-overlay.hidden {
  display: none;
}

/* ---- Command Palette ---- */
.command-palette-inner {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  max-width: 480px;
  width: 90%;
  max-height: 400px;
  overflow: hidden;
}

.command-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  box-sizing: border-box;
}

.command-input:focus { border-color: var(--accent); }

.command-list {
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.command-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}

.command-item:hover, .command-item:focus {
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
}

.shortcut-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}

.shortcut-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.shortcut-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.shortcut-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
}

.shortcut-close:hover {
  color: var(--text-primary);
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shortcut-group {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.shortcut-group:first-child { border-top: none; padding-top: 0; }

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.shortcut-row span {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.shortcut-row kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-primary);
  min-width: 24px;
  text-align: center;
}

.shortcut-hint {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.shortcut-hint kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 0.7rem;
}

/* ---- Error toast ---- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 999;
  animation: toastSlideIn 0.25s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ---- */

/* Phone landscape: compact header, side-by-side panels */
@media (max-height: 500px) and (orientation: landscape) {
  header { padding: 4px 12px; gap: 4px; }
  .social-proof { display: none; }
  .stats-bar { padding: 4px 12px; gap: 8px; }
  .stat-value { font-size: 0.9rem; }
  main { padding: 8px; }
  .top-section, .bottom-section { grid-template-columns: 1fr 1fr; }
  .panel-header h2 { font-size: 0.85rem; }
  .how-it-works, .usecases-section, .comparison-section, .cta-section { padding: 16px 12px; }
  .mobile-fab { bottom: 8px; right: 8px; width: 36px; height: 36px; font-size: 1rem; }
}

@media (max-width: 1024px) {
  .top-section, .bottom-section {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 820px) {
  /* Tablet: reduce panel min-heights when stacked */
  .panel { min-height: 260px; }
  .CodeMirror { min-height: 200px; }
  .integration-bar { gap: 8px; }
  .integration-badge { font-size: 0.7rem; padding: 4px 8px; }
  .quickstart-code { margin-top: 20px; }
  .arch-flow { gap: 10px; }
  .arch-node { padding: 12px 14px; }
  .arch-label { font-size: 0.85rem; }
  .arch-sub { font-size: 0.65rem; }
}

@media (max-width: 640px) {
  header {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .header-right {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  .header-right .pip-btn {
    font-size: 0.68rem;
    padding: 4px 8px;
  }

  .social-proof {
    justify-content: center;
  }

  main {
    padding: 12px;
  }

  .quick-actions {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .quick-actions::-webkit-scrollbar { display: none; }
  .quick-actions .action-btn {
    scroll-snap-align: start;
    flex-shrink: 0;
    min-width: 120px;
  }

  .preset-buttons {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;      /* Firefox */
  }

  .preset-buttons::-webkit-scrollbar {
    display: none;              /* Chrome/Safari */
  }

  .preset-btn {
    scroll-snap-align: start;
    flex-shrink: 0;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .key-benefits { margin-top: 16px; }
  .key-benefits li { font-size: 0.78rem; padding: 5px 0; }

  .framework-compat { gap: 4px; }
  .compat-item { font-size: 0.65rem; padding: 2px 6px; }

  .preset-divider {
    display: none;
  }

  /* Audit filter touch targets */
  .audit-filter {
    min-height: 32px;
    padding: 4px 12px;
    font-size: 0.72rem;
  }
  .audit-filters {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .audit-filters::-webkit-scrollbar { display: none; }

  /* Fade hint on right edge for scrollable presets */
  .panel-header {
    position: relative;
  }

  .comparison-table th:first-child,
  .comparison-table td.feature {
    font-size: 0.75rem;
    padding: 8px 10px;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .how-it-works {
    padding: 40px 16px;
  }

  .how-it-works h2 {
    font-size: 1.4rem;
    margin-bottom: 24px;
  }

  .step-card {
    padding: 24px 16px;
  }

  .arch-flow {
    flex-direction: column;
    gap: 6px;
  }
  .arch-node { min-width: unset; width: 100%; padding: 12px 16px; }
  .arch-arrow { transform: rotate(90deg); margin: 4px 0; }
  .arch-node[data-tip]:hover::after { display: none; }

  .step-icon {
    font-size: 1.6rem;
  }

  .adoption-speed {
    gap: 16px;
  }

  .adoption-value {
    font-size: 1.1rem;
  }

  .decision-matrix {
    font-size: 0.75rem;
  }
  .dm-row {
    grid-template-columns: 76px 1fr 120px;
    padding: 6px 10px;
  }
  .dm-risk { font-size: 0.68rem; }
  .dm-decision { font-size: 0.72rem; }

  .trust-signals {
    gap: 6px;
  }

  .trust-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
  }

  .comparison-section {
    padding: 40px 16px;
  }

  .comparison-section h2 {
    font-size: 1.4rem;
  }

  .stats-bar {
    gap: 12px;
    padding: 8px 12px;
  }

  .stat-item {
    min-width: 55px;
  }

  .stat-value {
    font-size: 1rem;
  }

  .usecases-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Touch-friendly form inputs */
  .form-row input {
    padding: 8px 10px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .run-btn, .run-all-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .action-btn {
    padding: 10px 12px;
    min-height: 44px;
  }

  .clear-btn {
    min-height: 36px;
  }

  .comparison-panels {
    font-size: 0.75rem;
  }

  .cta-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .footer-shortcuts {
    flex-direction: column;
    gap: 4px;
  }

  .integrations-bar {
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.7rem;
  }

  /* Architecture flow stacks vertically on mobile */
  .arch-flow {
    flex-direction: column;
    gap: 8px;
  }

  .arch-arrow {
    transform: rotate(90deg);
    padding: 4px 0;
  }

  .arch-decisions {
    flex-direction: row;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Code panels full-width */
  .quickstart-code {
    margin-left: -16px;
    margin-right: -16px;
    border-radius: 0;
  }

  /* Scrollable code tabs on mobile */
  .code-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .code-tabs::-webkit-scrollbar { display: none; }
  .code-tab {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.75rem;
  }
  .code-panel { padding: 12px 14px; }
  .code-panel code { font-size: 0.72rem; }

  /* Audit export dropdown: constrained on narrow screens */
  .export-menu {
    right: 0;
    left: auto;
    max-width: calc(100vw - 24px);
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Share modal fits screen */
  .share-modal-inner {
    width: 95vw;
    max-width: none;
    padding: 16px;
  }

  .share-links {
    flex-wrap: wrap;
    gap: 8px;
  }

  .share-link {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 120px;
    font-size: 0.8rem;
    padding: 10px 12px;
  }

  .share-url-row {
    flex-direction: column;
    gap: 6px;
  }

  .share-url-row .copy-share-btn {
    align-self: stretch;
  }

  /* Audit search: fixed width on mobile, no expand-on-focus push */
  .audit-search {
    width: 90px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .audit-search:focus {
    width: 120px;
  }

  /* Panel header: wrap gracefully when buttons overflow */
  .panel-header {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  /* Command palette: fullscreen on mobile */
  .command-palette-inner {
    width: 95%;
    max-width: none;
    max-height: 70vh;
  }
  .command-input {
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .command-item {
    padding: 10px 12px;
    min-height: 40px;
  }

  /* Shortcut overlay: scrollable on mobile */
  .shortcut-modal {
    max-height: 80vh;
    overflow-y: auto;
    width: 95vw;
    max-width: none;
  }
  .shortcut-row {
    padding: 6px 0;
  }

  /* Tour tooltip narrower */
  .tour-tooltip {
    max-width: 260px;
    font-size: 0.82rem;
  }

  /* Mobile FAB */
  .mobile-fab {
    display: flex;
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: calc(16px + env(safe-area-inset-right));
    z-index: 900;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 1.4rem;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    animation: fabEntrance 0.5s 1s ease both;
  }

  @keyframes fabEntrance {
    0% { opacity: 0; transform: scale(0) rotate(-90deg); }
    60% { transform: scale(1.15) rotate(10deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
  }

  .mobile-fab-menu {
    position: fixed;
    bottom: 72px;
    right: 16px;
    z-index: 899;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-fab-menu.hidden { display: none; }

  .fab-action {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    text-align: right;
    opacity: 0;
    transform: translateY(8px);
    animation: fabItemIn 0.2s ease forwards;
  }
  .fab-action:nth-child(1) { animation-delay: 0s; }
  .fab-action:nth-child(2) { animation-delay: 0.05s; }
  .fab-action:nth-child(3) { animation-delay: 0.1s; }
  .fab-action:nth-child(4) { animation-delay: 0.15s; }
  .fab-action:nth-child(5) { animation-delay: 0.2s; }
  @keyframes fabItemIn {
    to { opacity: 1; transform: translateY(0); }
  }

  .fab-action:hover {
    background: var(--accent);
    color: #fff;
  }
}

@media (min-width: 641px) {
  .mobile-fab, .mobile-fab-menu { display: none !important; }
}

/* Editor focus mode — expands editor, hides distractions */
.editor-focus-mode .top-section {
  grid-template-columns: 1fr;
}
.editor-focus-mode .top-section > :not(:first-child),
.editor-focus-mode .bottom-section,
.editor-focus-mode .how-it-works,
.editor-focus-mode .usecases-section,
.editor-focus-mode .comparison-section,
.editor-focus-mode .cta-section,
.editor-focus-mode footer { display: none; }
.editor-focus-mode .CodeMirror { min-height: 70vh; }
.editor-focus-mode .stats-bar { opacity: 0.5; }

/* Scroll-to-top button (mobile only) */
.scroll-top-btn {
  display: none;
}

@media (max-width: 640px) {
  .scroll-top-btn {
    display: flex;
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom));
    left: calc(16px + env(safe-area-inset-left));
    z-index: 898;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 1rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
  }
  .scroll-top-btn.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
  }
  .scroll-top-btn:active {
    transform: scale(0.9);
  }
}

@media (max-width: 400px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .usecases-grid {
    grid-template-columns: 1fr;
  }

  .preset-buttons {
    gap: 4px;
  }

  .preset-btn {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .step-card p {
    font-size: 0.75rem;
  }

  .comparison-table {
    font-size: 0.7rem;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 6px 8px;
  }
}

/* ---- How It Works Section ---- */
.how-it-works {
  padding: 60px 24px;
  text-align: center;
  max-width: 1000px;
  margin: 0 auto;
}

.how-it-works h2 {
  font-size: 1.8rem;
  margin-bottom: 40px;
  color: var(--text-primary);
}

.why-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto 32px;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid rgba(210, 153, 34, 0.3);
  background: rgba(210, 153, 34, 0.06);
  text-align: left;
}

.why-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 2px; }

.why-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.why-content strong { color: var(--text-primary); }

/* Before / After comparison */
.before-after {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto 28px;
}

.ba-col {
  flex: 1;
  padding: 14px 16px;
  border-radius: 10px;
  text-align: center;
}

.ba-col code {
  display: block;
  font-size: 0.8rem;
  margin-top: 8px;
  word-break: break-word;
}

.ba-before {
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}

.ba-before:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(248, 81, 73, 0.15);
}

.ba-before .ba-label { color: #f85149; }

.ba-after {
  background: rgba(63, 185, 80, 0.08);
  border: 1px solid rgba(63, 185, 80, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}

.ba-after:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(63, 185, 80, 0.15);
}

.ba-after .ba-label { color: #3fb950; }

.ba-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ba-vs {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.steps-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 48px;
}

.step-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  flex: 1;
  max-width: 280px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.step-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
}
.step-card:hover .step-number {
  background: var(--accent);
  color: var(--bg-primary);
}

/* Staggered entrance for step cards */
.reveal-visible .step-card:nth-child(1) { animation: stepReveal 0.4s 0.1s ease both; }
.reveal-visible .step-card:nth-child(3) { animation: stepReveal 0.4s 0.2s ease both; }
.reveal-visible .step-card:nth-child(5) { animation: stepReveal 0.4s 0.3s ease both; }

@keyframes stepReveal {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-number {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #000;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.step-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.step-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.step-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.step-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .steps-grid {
    flex-direction: column;
  }
  .step-arrow {
    transform: rotate(90deg);
  }
  .step-card {
    max-width: 100%;
  }
  .before-after {
    flex-direction: column;
    gap: 8px;
  }
  .ba-vs { display: none; }
}

/* Performance: skip rendering of off-screen below-fold sections */
.how-it-works,
.usecases-section,
.comparison-section,
.cta-section {
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}

/* ---- Comparison Section ---- */
.comparison-section {
  padding: 60px 24px;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.comparison-section h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.comparison-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

.comparison-table-wrap {
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.comparison-table th,
.comparison-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.comparison-table thead th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.comparison-table thead th.highlight {
  color: var(--accent);
}

.comparison-table td.feature {
  color: var(--text-secondary);
  font-weight: 500;
}

.comparison-table td.highlight {
  color: var(--risk-low);
  font-weight: 500;
}

.comparison-table tbody tr:hover {
  background: var(--bg-hover);
}
