/* CSS Variables for ABMeter Design System */
:root {
  /* Rust color palette (Stitch-inspired warm palette) */
  --rust-primary: #C55E5D;
  --rust-dark: #b05150;
  --rust-light: #EEDCDC;
  --rust-border-subtle: rgba(197, 94, 93, 0.2); /* Subtle rust-tinted border for info boxes */

  /* Page and sidebar backgrounds (warm off-white) */
  --bg-page: #faf9f7;
  --sidebar-bg: #f3f1ea;

  /* Audience colors for charts and cards (ordered by assignment index) */
  --audience-color-0: #C55E5D; /* Rust - control/baseline */
  --audience-color-1: #3b82a6; /* Muted blue - treatment 1 */
  --audience-color-2: #6b9b5f; /* Sage green - treatment 2 */
  --audience-color-3: #9b6b8f; /* Dusty purple - treatment 3 */
  --audience-color-4: #d97706; /* Amber/gold - treatment 4 */
  --audience-color-5: #4a4a4a; /* Dark gray - fallback */

  /* Destructive colors */
  --red-primary: #dc2626;
  --red-dark: #b91c1c;
  --red-light: #fee2e2;

  /* Success/positive indicator colors */
  --green-success: #059669;

  /* Warning/amber colors (for informational notice banners) */
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-300: #fcd34d;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-800: #92400e;
  --amber-900: #78350f;

  /* Navigation specific */
  --nav-header-bg: var(--sidebar-bg); /* Warm beige, matches sidebar */

  /* Neutral colors */
  --gray-50: #faf9f7;
  --gray-200: #e5e5e5;
  --gray-400: #d1d1d1;
  --gray-500: #6B6B6B;
  --gray-700: #4a4a4a;

  /* Table header background (warm tint) */
  --table-header-bg: #f4f3ef;

  /* Semantic aliases */
  --bg-hover: var(--gray-50);
  --text-primary: #1C1C1C;

  /* Transitions */
  --transition-standard: 0.15s;
}

/* Base body style — shared across all layouts */
.page-body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-page);
}

/* Prevent layout shifts from scrollbar appearance/disappearance */
html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

/* Reusable Button Classes */
.btn-rust-primary {
  background-color: var(--rust-primary);
  color: white;
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  font-weight: 400;
  border: 1px solid var(--rust-primary);
  border-radius: 0.25rem;
  cursor: pointer;
  transition: background-color var(--transition-standard) ease, border-color var(--transition-standard) ease;
}

.btn-rust-primary:hover:not(:disabled) {
  background-color: var(--rust-dark);
  border-color: var(--rust-dark);
}

.btn-rust-primary:disabled {
  background-color: var(--gray-200);
  border-color: var(--gray-400);
  color: var(--gray-700);
  cursor: not-allowed;
}

/* Destructive button variant */
.btn-rust-destructive {
  background-color: var(--red-primary);
  color: white;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: background-color var(--transition-standard) ease;
}

.btn-rust-destructive:hover:not(:disabled) {
  background-color: var(--red-dark);
}

.btn-rust-destructive:disabled {
  background-color: var(--gray-200);
  color: var(--gray-700);
  cursor: not-allowed;
}

/* Cancel/secondary button */
.btn-cancel {
  background-color: transparent;
  color: var(--gray-700);
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: 0.25rem;
  cursor: pointer;
  transition: background-color var(--transition-standard) ease;
}

.btn-cancel:hover:not(:disabled) {
  background-color: var(--gray-50);
}

.btn-cancel:disabled {
  color: var(--gray-400);
  border-color: var(--gray-200);
  cursor: not-allowed;
}

/* Text color utilities */
.text-rust {
  color: var(--rust-primary);
}

.text-rust-primary {
  color: var(--rust-primary);
}

.text-rust-dark {
  color: var(--rust-dark);
}

.text-muted {
  color: var(--gray-500);
}

/* Link styles */
.link-rust {
  color: var(--rust-primary);
  text-decoration: none;
  transition: color var(--transition-standard) ease;
}

.link-rust:hover {
  color: var(--rust-dark);
}

/* Destructive link style */
.link-destructive {
  color: var(--red-primary);
  text-decoration: none;
  transition: color var(--transition-standard) ease;
}

.link-destructive:hover {
  color: var(--red-dark);
}

/* Inline code/slug highlight */
.slug-highlight {
  color: var(--rust-primary);
  font-weight: 500;
}

/* Form input focus styles */
.input-rust:focus {
  outline: none;
  border-color: var(--rust-primary);
  box-shadow: 0 0 0 3px rgba(139, 72, 67, 0.1);
}

/* Checkbox/radio custom styles */
input[type="checkbox"].rust-checkbox:checked,
input[type="radio"].rust-radio:checked {
  accent-color: var(--rust-primary);
}

/* Form control accent color */
.accent-rust {
  accent-color: var(--rust-primary);
}

/* Apply rust accent color to all checkboxes and radio buttons by default */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--rust-primary);
}

/* Error styles for forms */
.error-container {
  background-color: var(--red-light);
  border: 1px solid var(--red-primary);
  padding: 1rem;
  border-radius: 0.25rem;
}

.error-text {
  color: var(--red-dark);
}

.error-list {
  color: var(--red-primary);
}

.text-required {
  color: var(--red-primary);
}

/* Action buttons for experiments/feature flags */
/* All experiment state transitions are high-impact and potentially costly.
   Use red for all state-changing actions to signal importance and prevent accidents. */
.action-button {
  background-color: var(--red-primary);
  color: white;
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  font-weight: 400;
  border: 1px solid var(--red-primary);
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all var(--transition-standard) ease;
}

.action-button:hover:not(:disabled) {
  background-color: var(--red-dark);
  border-color: var(--red-dark);
}

.action-button:disabled {
  background-color: var(--gray-200);
  border-color: var(--gray-400);
  color: var(--gray-700);
  cursor: not-allowed;
}

/* Utility classes for consistent spacing and styling */
.hover-rust:hover {
  color: var(--rust-dark);
}

.bg-rust-light {
  background-color: var(--rust-light);
}

.border-rust {
  border-color: var(--rust-primary);
}

.border-l-rust-primary {
  border-left-color: var(--rust-primary);
}

/* Clickable card with rust hover accent */
.card-action {
  transition: border-color 150ms, background-color 150ms;
}
.card-action:hover {
  border-color: var(--rust-primary);
  background-color: var(--rust-light);
}
.card-action:hover .card-action-title {
  color: var(--rust-primary);
}

/* Subtle rust-tinted border for info boxes, status indicators, non-critical alerts */
.border-rust-subtle {
  border-color: var(--rust-border-subtle);
}

/* Survey banner link — rust color contrasts clearly against neutral gray message text */
.survey-banner-link {
  color: var(--rust-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-standard) ease;
  font-weight: 500;
}
.survey-banner-link:hover {
  color: var(--rust-dark);
}

/* Toggle Switch Styles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 2.5rem; /* 40px */
  height: 1.5rem; /* 24px */
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-400);
  border-radius: 9999px;
  transition: background-color var(--transition-standard) ease, box-shadow var(--transition-standard) ease;
}

.toggle-track:hover {
  background-color: var(--gray-500);
}

.toggle-knob {
  position: absolute;
  content: "";
  height: 1.125rem; /* 18px - slightly larger for better visual weight */
  width: 1.125rem;
  left: 0.1875rem; /* 3px - centered with 24px track height */
  bottom: 0.1875rem;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--transition-standard) ease, box-shadow var(--transition-standard) ease;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

/* Checked state - rust background */
.toggle-switch input:checked ~ .toggle-track {
  background-color: var(--rust-primary);
}

.toggle-switch input:checked ~ .toggle-track:hover {
  background-color: var(--rust-dark);
}

.toggle-switch input:checked ~ .toggle-track .toggle-knob {
  transform: translateX(1rem); /* 16px - moves knob to right side */
}

/* Focus state for keyboard accessibility */
.toggle-switch input:focus ~ .toggle-track {
  box-shadow: 0 0 0 3px rgba(139, 72, 67, 0.15);
}

/* Disabled state */
.toggle-switch input:disabled ~ .toggle-track {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-switch input:disabled ~ .toggle-track:hover {
  background-color: var(--gray-400);
}

/* Label wrapper for toggle with text */
.toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-label-text {
  margin-right: 0.75rem;
  font-size: 0.875rem;
  color: var(--gray-700);
  font-weight: 400;
}

/* MCP Link Button - unlinked state with subtle call-to-action */
.mcp-link-button-unlinked {
  transition: all var(--transition-standard) ease;
}

.mcp-link-button-unlinked:hover {
  color: var(--rust-primary);
}

/* MCP Link Button - linked state shows AI assistant name for questions */
.mcp-link-button-linked {
  color: var(--gray-700);
  transition: all var(--transition-standard) ease;
}

.mcp-link-button-linked:hover {
  background-color: var(--gray-50);
  color: var(--text-primary);
}

/* MCP Icon Pulse - subtle color pulsing for unlinked chain icon */
.mcp-icon-pulse path {
  animation: mcp-icon-pulse 3s ease-in-out infinite;
}

@keyframes mcp-icon-pulse {
  0%, 100% {
    fill: var(--gray-400);
  }
  50% {
    fill: var(--gray-700);
  }
}

/* Flash messages */
.flash-message {
  line-height: 1.3;
  font-size: 0.875rem;
}

/* Flash message close button */
.flash-close {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: currentColor;
  opacity: 0.5;
  transition: opacity var(--transition-standard) ease;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flash-close:hover {
  opacity: 1;
}

.flash-close:focus {
  outline: none;
  opacity: 1;
}

/* ========================================
   Notice Banner System
   ========================================
   Standardized informational/warning notice banners.
   Use amber colors consistently across the app for:
   - Demo environment notices
   - Archived experiment notices
   - Important but non-destructive warnings
   - "Save this now" type messages
   ======================================== */

/* Section labels used in various lab views */
.section-label {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

/* Header Logo Text */
.header-logo-text {
  color: var(--rust-dark);
  font-size: 2rem;
  font-weight: 500;
  font-stretch: condensed;
  letter-spacing: 0.1em;
  margin-left: -0.25rem;
  margin-bottom: -0.2rem;
}

/* Navigation styles shared across lab and admin layouts */
/* Prevent layout shift during Turbo navigation - only for sidebar nav */
nav[data-controller="sidebar"] {
  min-width: 15rem; /* 240px, same as w-60 */
  max-width: 15rem;
}

.nav-link {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--gray-700);
  text-decoration: none;
  border-left: 4px solid transparent;
  transition: all var(--transition-standard) ease;
  font-size: 0.875rem;
  font-weight: 400;
}

.nav-link:hover {
  color: var(--text-primary);
  border-left-color: var(--gray-400);
  background: var(--gray-50);
}

.nav-link.active {
  color: var(--text-primary);
  border-left-color: var(--rust-primary);
  background: var(--rust-light);
  font-weight: 400;
}

.nav-section {
  margin-bottom: 1rem;
}

/* Collapsible sections have tighter spacing */
.nav-collapsible-section {
  margin-bottom: 0.25rem;
}

.nav-section-title {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding: 0.5rem 1rem;
  margin-bottom: 0;
  font-weight: 400;
}

.vertical-divider {
  width: 1px;
  background-color: var(--gray-200);
  margin: 0 1rem;
}

/* ==========================================================================
   Collapsible Sidebar
   ========================================================================== */

/* Sidebar states - expanded (default) and collapsed */
nav[data-controller="sidebar"] {
  width: 15rem; /* 240px - expanded */
  transition: width var(--transition-standard) ease;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: visible;
  z-index: 100; /* Ensure nav and its popups appear above main content */
}

nav[data-controller="sidebar"].collapsed {
  width: 3.5rem; /* 56px - collapsed, fits icon + padding */
  min-width: 3.5rem;
  max-width: 3.5rem;
}

/* Navigation link with icon support */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative; /* Required for tooltip positioning */
}

/* Icon styling */
.nav-link-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-standard) ease;
}

.nav-link:hover .nav-link-icon {
  opacity: 1;
}

.nav-link.active .nav-link-icon {
  opacity: 1;
}

/* Section icon styling - inline with text */
.nav-section-icon {
  flex-shrink: 0;
}

/* Section arrow for collapsible sections */
.nav-section-arrow {
  font-size: 0.625rem;
  margin-right: 0.25rem;
  margin-left: 0.5rem;
  transition: transform var(--transition-standard) ease;
  flex-shrink: 0;
}

/* Hide labels when sidebar is collapsed */
nav[data-controller="sidebar"].collapsed [data-sidebar-target="label"] {
  display: none;
}

/* Hide entire sections when collapsed (dropdowns, submenus) */
nav[data-controller="sidebar"].collapsed .nav-collapsible-section {
  display: none;
}

/* Adjust section title in collapsed state */
nav[data-controller="sidebar"].collapsed .nav-section-title {
  display: none;
}

/* Logo image - expanded state */
.nav-logo-image {
  height: 3rem;
  width: auto;
  margin-left: -1rem;
  margin-top: 0.25rem;
}

/* Logo adjustments when collapsed */
nav[data-controller="sidebar"].collapsed .nav-logo-link .header-logo-text {
  display: none;
}

nav[data-controller="sidebar"].collapsed .nav-logo-link {
  padding: 0;
}

nav[data-controller="sidebar"].collapsed .nav-logo-link > div {
  padding: 0.75rem !important;
  justify-content: center;
}

nav[data-controller="sidebar"].collapsed .nav-logo-image {
  margin: 0 !important;
  padding: 0 !important;
  height: 3.25rem !important;
  width: auto !important;
  object-fit: contain !important;
}

/* Sublink styling */
.nav-sublink {
  padding-left: 2.5rem;
  font-size: 0.8125rem;
}

/* Submenu container */
.nav-submenu {
  transition: max-height var(--transition-standard) ease;
}

/* Navigation Header Row - Logo + Toggle */
.nav-header-row {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--nav-header-bg);
}

.nav-header-row .nav-logo-link {
  display: block;
  flex: 1;
}

/* Tree Rendering Styles */
/* HTML Tree Rendering Styles */
.tree-html {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 2.0;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 0.25rem;
  padding: 1rem;
  overflow-x: auto;
  color: var(--gray-700);
}

/* Reset list styles */
.tree-html ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Indent nested children */
.tree-html .tree-children {
  padding-left: 1.6em;
}

/* Vertical continuation line on each node */
.tree-html .tree-node {
  position: relative;
  border-left: 1px solid var(--gray-500);
  padding-left: 1.2em;
}

/* Horizontal branch to label — sits at first-line midpoint */
.tree-html .tree-node::before {
  content: '';
  position: absolute;
  box-sizing: content-box;
  left: -1px;
  top: 0;
  width: 1em;
  height: calc(1lh / 2);
  border-bottom: 1px solid var(--gray-500);
}

/* Last child: stop the vertical line */
.tree-html .tree-node.tree-last {
  border-left-color: transparent;
}

/* Last child: draw the └ elbow */
.tree-html .tree-node.tree-last::before {
  border-left: 1px solid var(--gray-500);
  border-radius: 0 0 0 0.25em;
}

/* Root level: no connectors */
.tree-root > .tree-node {
  border-left: none;
  padding-left: 0;
}

.tree-root > .tree-node::before {
  display: none;
}

/* Property labels (hypothesis:, allocation:, etc.) - distinct from clickable links */
.tree-html .property-label {
  color: var(--text-primary);
  font-weight: 400;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* Muted text (system fields) - gray italic styling to indicate implicit/automatic */
.tree-html .tree-muted {
  color: var(--text-secondary);
  font-style: italic;
  opacity: 0.7;
}

/* Calm technical color scheme with muted rust tones */
.tree-html a.tree-slug-link {
  color: var(--rust-primary);
  text-decoration: none;
  cursor: pointer;
  display: inline;
  transition: color var(--transition-standard) ease;
  position: relative;
  font-weight: 500;
}

/* Ensure nested strong tags inherit link color */
.tree-html a.tree-slug-link strong {
  color: inherit;
  font-weight: 600;
}

/* Darker tone on hover - no underlines for modern look */
.tree-html a.tree-slug-link:hover {
  color: var(--rust-dark);
}

/* Primary resource - rust primary background matching buttons */
.tree-html a.tree-slug-link.primary-resource,
.tree-html strong.primary-resource {
  color: white;
  background-color: var(--rust-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Primary resource hover state - darker rust */
.tree-html a.tree-slug-link.primary-resource:hover {
  background-color: var(--rust-dark);
}

/* Code Block Styling */
.code-block {
  margin: 1rem 0;
}

.code-block pre {
  background-color: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 0;
  line-height: 1.45;
}

.code-block code {
  background: transparent;
  padding: 0;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  font-size: 0.8125rem; /* Slightly smaller for better readability */
  display: block;
}

/* Inline code styling */
.inline-code {
  background-color: var(--gray-50);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  font-size: 0.85em;
}

/* Inline syntax highlighting */
.highlight-inline {
  display: inline;
}

.highlight-inline span {
  font-size: inherit;
}

/* Resource Header Layout - Generic pattern for all resource types (experiments, spaces, etc.) */
/* Two-row layout: Row 1 = Resource identity (name + metadata), Row 2 = Navigation + Actions */
.resource-header {
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.resource-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.resource-header-row:not(:last-child) {
  margin-bottom: 0.75rem;
}

.resource-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.resource-title {
  font-size: 1.125rem;
  font-weight: 400;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
}

.resource-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Responsive behavior for smaller screens */
@media (max-width: 768px) {
  .resource-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .resource-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .resource-title {
    font-size: 1rem;
  }
}

/* Resource-specific title size variants */
.resource-title-large {
  font-size: 1.25rem;
}

@media (max-width: 768px) {
  .resource-title-large {
    font-size: 1rem;
  }
}

/* State Badge Styles - Unified for all badge sizes */
.state-badge {
  display: inline-flex;
  align-items: center;
  background-color: transparent;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-style: solid;
}

/* Size Variants */
.state-badge-small {
  padding: 0.125rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 400;
  border-width: 1px;
}

.state-badge-large {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 400;
  border-width: 1px;
}

/* State Colors - Single Source of Truth */
.state-badge-running,
.state-badge-enabled {
  color: var(--rust-primary);
  border-color: var(--rust-primary);
}

.state-badge-stopped {
  color: var(--rust-dark);
  border-color: var(--rust-primary);
}

.state-badge-draft,
.state-badge-archived,
.state-badge-disabled,
.state-badge-default {
  color: var(--gray-500);
  border-color: var(--gray-400);
}

.state-badge-draft {
  color: var(--rust-primary);
  border-color: var(--gray-400);
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  gap: 0;
}

.tab-link {
  padding: 0.25rem 1.5rem;
  color: var(--gray-700);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-standard) ease;
  font-size: 0.875rem;
  font-weight: 400;
  margin-bottom: -1px; /* Overlap with border-bottom of tab-nav */
  position: relative;
  white-space: nowrap;
}

.tab-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--gray-400);
}

.tab-link.active {
  color: var(--rust-primary);
  border-bottom-color: var(--rust-primary);
  font-weight: 400;
}

/* Inline Tab Navigation (for header placement) */
/* Uses background highlight instead of underline to avoid visual clutter with page borders */
.tab-nav-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tab-link-inline {
  padding: 0.5rem 1rem;
  color: var(--gray-700);
  text-decoration: none;
  background-color: transparent;
  border-radius: 0.25rem;
  transition: all var(--transition-standard) ease;
  font-size: 0.875rem;
  font-weight: 400;
}

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

.tab-link-inline.active {
  color: var(--rust-primary);
  background-color: var(--rust-light);
  font-weight: 400;
}

/* GitHub-style syntax highlighting theme */
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #6a737d; font-style: italic } /* Comment */
.highlight .k { color: #d73a49; font-weight: normal } /* Keyword */
.highlight .n { color: #24292e } /* Name */
.highlight .o { color: #d73a49; font-weight: normal } /* Operator */
.highlight .p { color: #24292e } /* Punctuation */
.highlight .cm { color: #6a737d; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #d73a49 } /* Comment.Preproc */
.highlight .c1 { color: #6a737d; font-style: italic } /* Comment.Single */
.highlight .cs { color: #6a737d; font-style: italic } /* Comment.Special */
.highlight .gd { background-color: #ffeef0 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gh { color: #24292e; font-weight: bold } /* Generic.Heading */
.highlight .gi { background-color: #f1f8e9 } /* Generic.Inserted */
.highlight .gp { color: #6a737d } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #6a737d; font-weight: bold } /* Generic.Subheading */
.highlight .kc { color: #d73a49 } /* Keyword.Constant */
.highlight .kd { color: #d73a49 } /* Keyword.Declaration */
.highlight .kn { color: #d73a49 } /* Keyword.Namespace */
.highlight .kp { color: #d73a49 } /* Keyword.Pseudo */
.highlight .kr { color: #d73a49; font-weight: normal } /* Keyword.Reserved */
.highlight .kt { color: #d73a49 } /* Keyword.Type */
.highlight .m { color: #005cc5 } /* Literal.Number */
.highlight .s { color: #032f62 } /* Literal.String */
.highlight .na { color: #24292e } /* Name.Attribute */
.highlight .nb { color: #005cc5 } /* Name.Builtin */
.highlight .nc { color: #6f42c1 } /* Name.Class */
.highlight .no { color: #005cc5 } /* Name.Constant */
.highlight .nd { color: #d73a49 } /* Name.Decorator */
.highlight .ni { color: #24292e } /* Name.Entity */
.highlight .ne { color: #6f42c1 } /* Name.Exception */
.highlight .nf { color: #6f42c1 } /* Name.Function */
.highlight .nl { color: #24292e } /* Name.Label */
.highlight .nn { color: #24292e } /* Name.Namespace */
.highlight .nx { color: #24292e } /* Name.Other */
.highlight .py { color: #24292e } /* Name.Property */
.highlight .nt { color: #22863a } /* Name.Tag */
.highlight .nv { color: #24292e } /* Name.Variable */
.highlight .ow { color: #d73a49; font-weight: normal } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #005cc5 } /* Literal.Number.Bin */
.highlight .mf { color: #005cc5 } /* Literal.Number.Float */
.highlight .mh { color: #005cc5 } /* Literal.Number.Hex */
.highlight .mi { color: #005cc5 } /* Literal.Number.Integer */
.highlight .mo { color: #005cc5 } /* Literal.Number.Oct */
.highlight .sa { color: #d73a49 } /* Literal.String.Affix */
.highlight .sb { color: #032f62 } /* Literal.String.Backtick */
.highlight .sc { color: #032f62 } /* Literal.String.Char */
.highlight .dl { color: #d73a49 } /* Literal.String.Delimiter */
.highlight .sd { color: #032f62; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #032f62 } /* Literal.String.Double */
.highlight .se { color: #032f62 } /* Literal.String.Escape */
.highlight .sh { color: #032f62 } /* Literal.String.Heredoc */
.highlight .si { color: #005cc5 } /* Literal.String.Interpol */
.highlight .sx { color: #032f62 } /* Literal.String.Other */
.highlight .sr { color: #032f62 } /* Literal.String.Regex */
.highlight .s1 { color: #032f62 } /* Literal.String.Single */
.highlight .ss { color: #005cc5 } /* Literal.String.Symbol */
.highlight .bp { color: #005cc5 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #6f42c1 } /* Name.Function.Magic */
.highlight .vc { color: #24292e } /* Name.Variable.Class */
.highlight .vg { color: #24292e } /* Name.Variable.Global */
.highlight .vi { color: #e36209 } /* Name.Variable.Instance */
.highlight .vm { color: #24292e } /* Name.Variable.Magic */
.highlight .il { color: #005cc5 } /* Literal.Number.Integer.Long */

/* ==========================================================================
   Chart Page Wrapper - Consistent max-width for chart pages
   ========================================================================== */

.chart-page-wrapper {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* ==========================================================================
   Exposure Charts - Shared styles for experiments and feature flags
   ========================================================================== */

/* Time Range Controls */
.time-range-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--gray-700);
  text-decoration: none;
  font-weight: 400;
  transition: color var(--transition-standard) ease;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}

.time-range-link:hover {
  color: var(--rust-primary);
}

.time-range-link.active {
  color: var(--rust-primary);
  font-weight: 400;
}

/* Exposure Chart Layout */
.exposure-chart-main {
  position: relative;
  height: 300px;
}

/* Exposure Stats Summary (Feature Flags) */
.exposure-stats-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

/* Responsive Card Grid (shared pattern) */
.exposure-legend-panel,
.effects-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* Effects uses compact gap */
.effects-cards-grid {
  gap: 0.75rem;
}

/* Audience Stats Cards (Experiments) */
.audience-stats-card {
  background: #f9fafb;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  padding: 0.875rem;
  transition: all var(--transition-standard) ease;
}

.audience-stats-card:hover {
  border-color: #d1d5db;
  background: white;
}

.audience-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.audience-color-indicator {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.audience-allocation {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  margin-bottom: 0.625rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--gray-200);
}

/* Metrics Grid */
.audience-metrics {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Responsive Design */
@media (max-width: 640px) {
  .exposure-legend-panel,
  .effects-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Effects Charts - Statistical analysis visualization for experiments
   Variation 6: Left Accent Bar
   - Left accent border (3px) shows variant color
   - Left-aligned grid layout (labels left, values right)
   - Uppercase labels with monospace font
   - Neutral colors throughout (no green/red for lift)
   ========================================================================== */

/* Effects Page - Inline Layout (Compact) */
.effects-section-title {
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gray-500);
  margin: 0 0 0.5rem 0;
}

.effects-section-date-range {
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--gray-500);
  margin-left: 0.25rem;
}

/* Archived experiment notice banner */
.effects-archived-notice {
  padding: 0.625rem 0.875rem;
  margin-bottom: 0.75rem;
  background-color: var(--amber-100);
  border: 1px solid var(--amber-300);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--amber-800);
}

.effects-notice-link {
  color: var(--amber-800);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.effects-notice-link:hover {
  color: var(--amber-900);
}

.effects-note-link {
  font-style: normal;
}

/* Same look as the numbered markers drawn on statistics-effects-card.png */
.stats-marker {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.375rem;
  border-radius: 9999px;
  background-color: var(--rust-primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  vertical-align: text-bottom;
}

/* Wrapper for metric selector with arrow indicator */
.effects-metric-selector-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Arrow indicator for metric selection */
.effects-metric-arrow {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  color: var(--amber-600);
  animation: effects-arrow-pulse 1.5s ease-in-out infinite;
  margin-right: 0.375rem;
}

.effects-metric-arrow svg {
  width: 1.125rem;
  height: 1.125rem;
}

@keyframes effects-arrow-pulse {
  0%, 100% {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
  50% {
    opacity: 0.6;
    transform: translateY(-50%) translateX(3px);
  }
}

/* Controls row: dropdowns left, formula right */
.effects-controls-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
  gap: 1rem;
  flex-wrap: wrap;
}

.effects-controls-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.effects-dropdown-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.effects-dropdown-label {
  font-size: 0.6875rem;
  color: var(--gray-500);
  font-weight: 400;
}

/* Metric Selector - Stacked layout */
.effects-metric-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.effects-metric-label {
  font-size: 0.6875rem;
  color: var(--gray-500);
  font-weight: 400;
}

/* Attribution Window Badges */
.effects-attribution-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.effects-attribution-header {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
}

.effects-attribution-label {
  font-size: 0.6875rem;
  color: var(--gray-500);
  font-weight: 400;
}

.effects-attribution-badges {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.effects-attribution-badge {
  padding: 0.125rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--gray-700);
  background-color: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all var(--transition-standard) ease;
  white-space: nowrap;
}

.effects-attribution-badge:hover {
  color: var(--text-primary);
  border-color: var(--gray-400);
  background-color: var(--gray-50);
}

.effects-attribution-badge.active {
  color: var(--rust-primary);
  border-color: var(--rust-primary);
  background-color: var(--rust-light);
}

.effects-attribution-badge:focus-visible {
  outline: 2px solid var(--rust-primary);
  outline-offset: 1px;
}

.effects-attribution-help {
  font-size: 0.625rem;
  color: var(--gray-500);
  font-style: italic;
}

.effects-attribution-static {
  font-size: 0.75rem;
  color: var(--gray-600);
  font-weight: 400;
}

.effects-inline-dropdown {
  padding: 0.25rem 1.5rem 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 0.25rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%234a4a4a' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.375rem center;
  appearance: none;
  cursor: pointer;
  transition: border-color var(--transition-standard) ease;
  color: var(--text-primary);
}

.effects-inline-dropdown:hover {
  border-color: var(--gray-400);
}

.effects-inline-dropdown:focus {
  outline: none;
  border-color: var(--rust-primary);
}

.effects-period-value {
  font-size: 0.75rem;
  color: var(--gray-700);
}

/* Formula Display - Right-aligned in controls row */
.effects-formula-display {
  font-size: 0.75rem;
  color: var(--gray-500);
  padding: 0.375rem 0.625rem;
  background: var(--gray-50);
  border-radius: 0.25rem;
  text-align: right;
  margin-left: auto;
  flex-shrink: 0;
}

.effects-formula-display .formula-rendered math {
  color: var(--gray-700);
}

/* Responsive: Stack controls on small screens */
@media (max-width: 768px) {
  .effects-controls-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .effects-controls-left {
    width: 100%;
  }

  .effects-formula-display {
    width: 100%;
    text-align: center;
  }
}

/* Effects Chart Layout */
.effects-chart-container {
  position: relative;
  height: 300px;
}

/* Effect Card - Left Accent Bar Style (Compact) */
.effect-card {
  background: white;
  border-top: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
  border-left-width: 3px;
  border-left-style: solid;
  border-left-color: var(--audience-color-1); /* Default treatment color, overridden via inline style */
  border-radius: 0;
  padding: 0.625rem 0.75rem 0.625rem 0.875rem;
  transition: border-color var(--transition-standard) ease;
}

.effect-card:hover {
  border-top-color: var(--gray-400);
  border-right-color: var(--gray-400);
  border-bottom-color: var(--gray-400);
}

/* Control/baseline cards use audience-color-0 (rust) */
.effect-card.baseline {
  border-left-color: var(--audience-color-0);
}

/* Placeholder state - subtle visual indication that data is pending */
.effect-card.placeholder-card {
  opacity: 0.85;
}

.placeholder-value {
  color: var(--gray-500);
}

/* Effect Card Header */
.effect-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
}

.effect-audience-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.effect-baseline-badge {
  font-size: 0.625rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-200);
  padding: 0.125rem 0.375rem;
  border-radius: 2px;
  margin-left: auto;
}

/* Data Row - Grid layout for label/value pairs */
.effect-data-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.effect-data-row:last-child {
  margin-bottom: 0;
}

.effect-data-label {
  font-size: 0.625rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  white-space: nowrap;
}

.effect-data-value {
  font-size: 0.75rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  color: var(--gray-700);
  text-align: right;
}

/* Lift value - restrained styling, neutral colors only */
.effect-data-value.lift-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--gray-700);
}

/* Section divider within card */
.effect-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 0.375rem 0;
}

/* Error state for comparison */
.effect-error-message {
  font-size: 0.75rem;
  color: var(--amber-600);
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
  background: var(--amber-50);
  border-radius: 0.25rem;
  margin-top: 0.5rem;
}

/* Effect Summary Parameters - Metadata display below section heading */
.effect-summary-params {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.effect-summary-param {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.effect-summary-param-label {
  font-size: 0.6875rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  white-space: nowrap;
}

.effect-summary-param-value {
  font-size: 0.75rem;
  color: var(--gray-700);
}

/* Formula values use monospace for code-like appearance */
.effect-summary-param-formula {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  font-size: 0.6875rem;
  color: var(--gray-500);
}

/* Responsive Design for Effects */
@media (max-width: 640px) {
  .effect-summary-params {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* ==========================================================================
   Sortable Table Headers - Ransack sort_link styling
   Outline chevron icons: always visible (muted), apparent on hover/active
   ========================================================================== */

.sort_link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* Sort indicator - double chevron icon */
.sort_link::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 14px;
  margin-left: 0.375rem;
  vertical-align: middle;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='14' viewBox='0 0 8 14'%3E%3Cpath d='M1 5 L4 2 L7 5' stroke='%231a1a1a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M1 9 L4 12 L7 9' stroke='%231a1a1a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: opacity var(--transition-standard) ease;
}

/* Hover - both arrows become apparent */
.sort_link:hover::after {
  opacity: 1;
}

/* Active ASC - up arrow apparent, down arrow muted */
.sort_link.asc::after {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='14' viewBox='0 0 8 14'%3E%3Cpath d='M1 5 L4 2 L7 5' stroke='%231a1a1a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M1 9 L4 12 L7 9' stroke='%231a1a1a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round' opacity='0.35'/%3E%3C/svg%3E");
}

/* Active DESC - down arrow apparent, up arrow muted */
.sort_link.desc::after {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='14' viewBox='0 0 8 14'%3E%3Cpath d='M1 5 L4 2 L7 5' stroke='%231a1a1a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round' opacity='0.35'/%3E%3Cpath d='M1 9 L4 12 L7 9' stroke='%231a1a1a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Delete Row - Design 4G layout for delete sections
   Reason on left (when blocked), button on right
   ========================================================================== */

.delete-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
}

.delete-row .delete-reason {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* ==========================================================================
   Collapsible Sidebar - Tooltips, Popups, and Bottom Section
   ========================================================================== */

/* Tooltips - appear on hover when sidebar is collapsed */
.nav-tooltip {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-primary);
  color: white;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-standard) ease;
  margin-left: 8px;
  font-weight: 400;
  z-index: 1001;
}

.nav-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--text-primary);
}

/* Show tooltips only when sidebar is collapsed */
nav[data-controller="sidebar"].collapsed .nav-link:hover .nav-tooltip {
  opacity: 1;
}

nav[data-controller="sidebar"].collapsed .popup-trigger:hover .nav-tooltip {
  opacity: 1;
}

nav[data-controller="sidebar"].collapsed .sidebar-toggle-bottom:hover .nav-tooltip {
  opacity: 1;
}

/* Popup Menus - for secondary navigation items */
.popup-trigger {
  position: relative;
}

.popup-menu {
  position: absolute;
  left: 100%;
  top: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 220px;
  padding: 0.5rem 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-8px);
  transition: all var(--transition-standard) ease;
  margin-left: 8px;
  z-index: 9999;
}

.popup-trigger:hover .popup-menu,
.popup-menu:hover {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* Hide tooltip when popup is visible - use display none to fully remove */
.popup-trigger:hover .nav-tooltip {
  display: none !important;
}

.popup-header {
  padding: 0.5rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9a9a9a;
}

.popup-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: background var(--transition-standard) ease;
}

.popup-item:hover {
  background: #f5f5f5;
  color: var(--text-primary);
}

.popup-item .nav-link-icon {
  width: 16px;
  height: 16px;
}

.popup-item.active {
  color: var(--rust-primary);
  font-weight: 500;
  background: var(--rust-light);
}

.popup-item.active::after {
  content: '';
  margin-left: auto;
  width: 6px;
  height: 6px;
  background: var(--rust-primary);
  border-radius: 50%;
}

.popup-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 0.5rem 0;
}

/* Chevron for popup triggers */
.nav-chevron {
  margin-left: auto;
  opacity: 0.5;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

nav[data-controller="sidebar"].collapsed .nav-chevron {
  display: none;
}

/* Bottom Section - pinned to bottom of sidebar */
.nav-bottom-section {
  border-top: 1px solid var(--gray-200);
  padding: 0.5rem 0;
  flex-shrink: 0;
}

/* Sidebar Toggle Button - Bottom placement */
.sidebar-toggle-bottom {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--gray-700);
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--transition-standard) ease;
  text-align: left;
  position: relative; /* Required for tooltip positioning */
}

.sidebar-toggle-bottom:hover {
  background: var(--gray-50);
}

.sidebar-toggle-bottom .nav-link-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-toggle-bottom:hover .nav-link-icon {
  opacity: 1;
}

nav[data-controller="sidebar"].collapsed .sidebar-toggle-bottom {
  justify-content: center;
  padding: 0.75rem;
}

nav[data-controller="sidebar"].collapsed .sidebar-toggle-bottom span:not(.nav-link-icon):not(.nav-tooltip) {
  display: none;
}

/* Nav divider */
.nav-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 0.5rem 1rem;
  flex-shrink: 0;
}

nav[data-controller="sidebar"].collapsed .nav-divider {
  margin: 0.5rem 0.5rem;
}

/* Disabled popup items (coming soon) */
.popup-item.popup-item-disabled {
  color: var(--gray-400);
  cursor: default;
}

.popup-item.popup-item-disabled:hover {
  background: transparent;
  color: var(--gray-400);
}

/* Badge for popup items (e.g., "Soon") */
.popup-item-badge {
  margin-left: auto;
  font-size: 0.5625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-100);
  color: var(--gray-400);
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  line-height: 1;
}

/* Adjust nav link for popup trigger styling */
.nav-link.popup-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Account popup - opens upward (bottom of popup aligns with bottom of trigger) */
.popup-menu.popup-menu-up {
  top: auto;
  bottom: 0;
}

/* OAuth sign-in buttons (login page)
 * Follows Google Sign-In branding guidelines (light theme):
 * https://developers.google.com/identity/branding-guidelines
 * GitHub logo uses official brand color #101411.
 */
.btn-oauth {
  background-color: #ffffff;
  border: 1px solid #747775;
  color: #1f1f1f;
  transition: border-color var(--transition-standard) ease, background-color var(--transition-standard) ease;
}

.btn-oauth:hover {
  border-color: #1f1f1f;
  background-color: #f8f8f8;
}

/* Design note illustrations: the SVGs carry no width or height, so each sits in a
   fixed-size box; Safari otherwise stretches a bare SVG flex item */
.note-illustration {
  display: block;
  width: 100%;
  height: 100%;
}

/* The index list: each entry is a white card, and the title link stretches
   over the whole card, so the card is one link for the mouse and one tab
   stop for the keyboard. On a narrow column the illustration sits above the
   title. A container query, not a media query, because the open sidebar
   narrows the column on a tablet. */
.note-entries {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.note-entry {
  position: relative;
  padding: 1.25rem;
  border-radius: 1.25rem;
  background-color: #fff;
  box-shadow: 0 0 0 1px rgba(40, 30, 10, 0.05), 0 1px 2px rgba(40, 30, 10, 0.04), 0 4px 16px -4px rgba(40, 30, 10, 0.06);
  transition: box-shadow 0.2s;
}

.note-entry-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.note-entry-link:focus-visible {
  outline: none;
}

/* Decorative arrow, shown with the ring on hover or keyboard focus */
.note-entry::before {
  content: "\2192";
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  font-size: 0.9rem;
  color: #fff;
  background-color: var(--rust-primary);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s, transform 0.2s;
}

.note-entry:hover,
.note-entry:has(.note-entry-link:focus-visible) {
  box-shadow: 0 0 0 1.5px rgba(197, 94, 93, 0.55), 0 12px 28px -10px rgba(197, 94, 93, 0.25);
}

.note-entry:hover::before,
.note-entry:has(.note-entry-link:focus-visible)::before {
  opacity: 1;
  transform: none;
}

.note-entry-head {
  padding-right: 2.5rem;
}

.note-entry-illustration {
  width: 5rem;
  height: 5rem;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
  background-color: var(--sidebar-bg);
}

.note-entry-summary {
  margin-top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .note-entry,
  .note-entry::before {
    transition: none;
  }
}

/* Title and date beside the tile, summary below both at full width, so
   every card has the same shape whatever the title and summary lengths */
@container (min-width: 26rem) {
  .note-entry {
    padding: 1.5rem;
  }

  .note-entry:has(.note-entry-illustration) {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr);
    grid-template-areas:
      "tile head"
      "summary summary";
    column-gap: 1.25rem;
    align-items: center;
  }

  .note-entry-illustration {
    grid-area: tile;
    width: 6rem;
    height: 6rem;
    padding: 0.625rem;
    margin: 0;
  }

  .note-entry-head {
    grid-area: head;
  }

  .note-entry-summary {
    grid-area: summary;
    margin-top: 0.75rem;
  }
}

/* The article header: the same tile, larger, left of the title while the
   column has room and above it when it does not */
.note-header {
  container-type: inline-size;
}

.note-header-illustration {
  width: 6rem;
  height: 6rem;
  padding: 0.625rem;
  margin-bottom: 1.25rem;
  border-radius: 0.875rem;
  background-color: var(--sidebar-bg);
}

@container (min-width: 30rem) {
  .note-header-row:has(.note-header-illustration) {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    column-gap: 2rem;
    align-items: center;
  }

  .note-header-illustration {
    width: 9rem;
    height: 9rem;
    padding: 1rem;
    margin-bottom: 0;
  }
}

/* Previous and next links under a note: two white cards side by side,
   stacked on a phone; "next" keeps the right column when it stands alone */
.note-pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .note-pager {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .note-pager-next {
    grid-column: 2;
    text-align: right;
  }
}

.note-pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  background-color: #fff;
  box-shadow: 0 0 0 1px rgba(40, 30, 10, 0.05), 0 1px 2px rgba(40, 30, 10, 0.04), 0 4px 16px -4px rgba(40, 30, 10, 0.06);
  transition: box-shadow 0.2s;
}

.note-pager-link:hover,
.note-pager-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1.5px rgba(197, 94, 93, 0.55), 0 12px 28px -10px rgba(197, 94, 93, 0.25);
}

.note-pager-title {
  color: #1a1a1a;
  font-size: 0.95rem;
  line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .note-pager-link {
    transition: none;
  }
}

/* Design note prose: Markdown output has no utility classes */
.note-prose {
  max-width: 42rem;
  color: var(--gray-700);
  font-size: 1rem;
  line-height: 1.7;
}

.note-prose > * + * {
  margin-top: 1.25rem;
}

.note-prose h2 {
  margin-top: 2.5rem;
  font-size: 1.25rem;
  font-weight: 500;
  color: #1a1a1a;
}

.note-prose h3 {
  margin-top: 2rem;
  font-size: 1.0625rem;
  font-weight: 500;
  color: #1a1a1a;
}

.note-prose a {
  color: var(--rust-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.note-prose ul,
.note-prose ol {
  padding-left: 1.5rem;
}

.note-prose ul { list-style: disc; }
.note-prose ol { list-style: decimal; }

.note-prose li + li {
  margin-top: 0.375rem;
}

.note-prose blockquote {
  border-left: 2px solid var(--gray-200);
  padding-left: 1rem;
  color: var(--gray-500);
}

.note-prose :not(pre) > code {
  background-color: var(--gray-50);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  font-size: 0.875em;
}

.note-prose table {
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.note-prose th,
.note-prose td {
  padding: 0.375rem 0.75rem;
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
}

.note-prose th {
  font-weight: 500;
  color: #1a1a1a;
}

.note-prose div.formula-container {
  display: block;
  overflow-x: auto;
  text-align: center;
  font-size: 1.25rem;
}

.note-prose span.formula-container {
  font-size: 1em;
}

/* The lab layout grows to its widest line. A zero width keeps a long code line
   out of that measure, so the box fills the column and scrolls instead. */
.note-prose .code-block pre {
  width: 0;
  min-width: 100%;
}

/* Tighten tables on a phone so a table row is not the widest line either */
@media (max-width: 640px) {
  .note-prose th,
  .note-prose td {
    padding: 0.25rem 0.5rem;
  }
}

/* Flash card tutor (/lab/flashcards) */
.flashcard-ink {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: var(--ink);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #9ca3af;
}

.flashcard-ink[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--rust-primary, #b4472e);
}

.flashcard-ok {
  color: var(--gray-700);
}

.flashcard-miss {
  color: #b91c1c;
}

/* Full-screen writing: the stage covers the viewport, one 56px bar holds the question chip, the
   tools and Check answer, and the canvas takes the rest. The question opens over the canvas. */
.flashcard-stage.flashcard-focus {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
  background: #fff;
  overflow: auto;
}

.flashcard-focusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 56px;
  padding: 0 0.75rem;
  border-bottom: 1px solid #e7e3dc;
  background: #faf8f5;
}

.flashcard-icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: var(--gray-700);
}

.flashcard-chip {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 44px;
  padding: 0 0.75rem;
  border: 1px solid #e7e3dc;
  border-radius: 10px;
  background: #fff;
  color: var(--gray-700);
  text-align: left;
}

.flashcard-chip-meta {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.flashcard-chip-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #1c1c1c;
}

.flashcard-chip-text * {
  display: inline;
  margin: 0;
}

.flashcard-focus-tools {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flashcard-tools .btn-cancel {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.flashcard-focusbar .flashcard-tools {
  flex-wrap: nowrap;
  gap: 0.125rem;
  margin: 0;
  padding: 0 0.375rem;
  border-left: 1px solid #e7e3dc;
  border-right: 1px solid #e7e3dc;
}

.flashcard-focusbar .flashcard-tools .btn-cancel {
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
}

.flashcard-focusbar .flashcard-tool-label {
  display: none;
}

.flashcard-focusbar .flashcard-tools .ml-auto {
  margin-left: 0.25rem;
}

.flashcard-judged .flashcard-focus-tools,
.flashcard-judged .flashcard-focusbar [data-flashcards-target="inputNav"] {
  display: none;
}

.flashcard-focusbar [data-flashcards-target="inputNav"] {
  flex-shrink: 0;
}

.flashcard-focus .flashcard-answer-head {
  display: none;
}

.flashcard-stage.flashcard-focus:not(.flashcard-prompt-open) .flashcard-card {
  display: none;
}

.flashcard-focus.flashcard-prompt-open .flashcard-card {
  position: absolute;
  top: calc(56px + 0.5rem + env(safe-area-inset-top, 0px));
  left: 0.75rem;
  right: 0.75rem;
  z-index: 1;
  max-height: 40vh;
  overflow: auto;
  padding: 1rem 1.25rem;
  box-shadow: 0 6px 24px rgba(40, 30, 10, 0.12);
}

.flashcard-focus .flashcard-answer {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0;
}

.flashcard-focus .flashcard-verdict {
  margin: 0.5rem 0.75rem;
}

.flashcard-focus .flashcard-answer,
.flashcard-focus .flashcard-verdict {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.flashcard-focus .flashcard-answer [data-flashcards-target="canvasWrap"] {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.flashcard-focus .flashcard-canvas {
  flex: 1 1 auto;
  height: auto;
  min-height: 12rem;
}

.flashcard-focus .flashcard-answer textarea {
  flex: 1 1 auto;
  min-height: 12rem;
}

.flashcard-focus .flashcard-actions {
  margin-top: 0.5rem;
}

.flashcard-focus .flashcard-verdict {
  overflow: auto;
}

.flashcard-text p + p {
  margin-top: 0.75rem;
}

.flashcard-text math[display="block"] {
  display: block;
  margin: 0.75rem 0;
  overflow-x: auto;
}

.flashcard-text table {
  margin: 0.75rem 0;
  border-collapse: collapse;
}

.flashcard-text th,
.flashcard-text td {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--color-gray-200, #e5e7eb);
}

/* While writing, a resting palm must not start a text selection or the iOS callout. */
.flashcard-writing {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.flashcard-canvas {
  touch-action: none;
  height: 24rem;
}

@media (orientation: landscape) and (min-width: 1000px) {
  .flashcard-canvas {
    height: 30rem;
  }
}

/* Questions and Answers: each group is one white card, each question a
   native <details>, so closed answers stay in the HTML for search engines
   and find-in-page */
.faq-group-heading {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.faq-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.45rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--gray-500);
  background-color: var(--sidebar-bg);
}

.faq-group {
  padding: 0.25rem 1.5rem;
  border-radius: 1.25rem;
  background-color: #fff;
  box-shadow: 0 0 0 1px rgba(40, 30, 10, 0.05), 0 1px 2px rgba(40, 30, 10, 0.04), 0 4px 16px -4px rgba(40, 30, 10, 0.06);
}

.faq-item {
  padding: 1.1rem 0;
}

.faq-item + .faq-item {
  border-top: 1px solid #efebe3;
}

.faq-item summary {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  list-style: none;
  cursor: pointer;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary:hover h3 {
  color: var(--rust-dark);
}

.faq-item summary:focus-visible {
  outline: 2px solid var(--rust-primary);
  outline-offset: 4px;
  border-radius: 0.25rem;
}

.faq-chevron {
  width: 0.55rem;
  height: 0.55rem;
  margin: 0.45rem 0 0 0.2rem;
  border-right: 2px solid var(--rust-primary);
  border-bottom: 2px solid var(--rust-primary);
  transform: rotate(-45deg);
  transition: transform 0.2s;
}

.faq-item[open] .faq-chevron {
  transform: rotate(45deg);
}

.faq-answer {
  max-width: 46rem;
  padding: 0.5rem 0 0.25rem 2rem;
  line-height: 1.6;
}

@media (max-width: 640px) {
  .faq-group {
    padding: 0.25rem 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .faq-chevron {
    transition: none;
  }
}

/* Home hero: a white card with the illustration on a beige circle in its
   bottom-right corner, cut off by the card edge. Each sentence of the title
   keeps its own line. On a narrow column the drawing sits under the button. */
.home-page {
  container-type: inline-size;
}

.home-hero {
  position: relative;
  overflow: hidden;
  padding: 1.75rem 1.75rem 13rem;
  border-radius: 1.5rem;
  background-color: #fff;
  box-shadow: 0 0 0 1px rgba(40, 30, 10, 0.05), 0 1px 2px rgba(40, 30, 10, 0.04), 0 4px 16px -4px rgba(40, 30, 10, 0.06);
}

.home-hero::after {
  content: "";
  position: absolute;
  right: -4rem;
  bottom: -4rem;
  width: 16rem;
  height: 16rem;
  border-radius: 9999px;
  background-color: var(--sidebar-bg);
}

.home-hero-art {
  position: absolute;
  right: -1rem;
  bottom: -1.5rem;
  z-index: 1;
  width: 13rem;
  height: 13rem;
}

.home-hero-text {
  position: relative;
  z-index: 1;
}

.home-hero-title {
  font-size: 1.625rem;
}

.home-hero-title span {
  display: block;
  text-wrap: balance;
}

@container (max-width: 30rem) {
  .home-hero {
    padding: 1.25rem 1.25rem 11rem;
  }

  .home-hero-title {
    font-size: 1.375rem;
  }

  .home-hero-art {
    width: 11rem;
    height: 11rem;
  }
}

@container (min-width: 44rem) {
  .home-hero {
    padding: 2.75rem 17rem 2.75rem 2.75rem;
  }

  .home-hero::after {
    right: -6rem;
    bottom: -6rem;
    width: 24rem;
    height: 24rem;
  }

  .home-hero-art {
    right: -2rem;
    bottom: -2.5rem;
    width: 17rem;
    height: 17rem;
  }

  .home-hero-title {
    font-size: 1.875rem;
  }
}

/* Core Concepts. A container query, not a media query, because the open
   sidebar narrows the column. Below its minimum width the map scrolls inside
   its card, so its text stays readable. */
.concepts-page {
  container-type: inline-size;
}

.concepts-map {
  overflow-x: auto;
  margin: 0 0 1.5rem;
  padding: 1.25rem;
  border-radius: 1.5rem;
  background-color: #fff;
  box-shadow: 0 0 0 1px rgba(40, 30, 10, 0.05), 0 1px 2px rgba(40, 30, 10, 0.04), 0 4px 16px -4px rgba(40, 30, 10, 0.06);
}

.concepts-map svg {
  display: block;
  width: 100%;
  min-width: 27.25rem;
  max-width: 36rem;
  height: auto;
  margin: 0 auto;
}

.concepts-map figcaption {
  max-width: 36rem;
  margin: 0.75rem auto 0;
}

.concepts-lead {
  display: grid;
  gap: 0 1.5rem;
  margin-bottom: 1rem;
}

.concepts-lead > p {
  margin-bottom: 1rem;
}

.concepts-figure {
  overflow-x: auto;
  margin: 0;
  max-width: 26.25rem;
}

.concepts-figure svg {
  display: block;
  width: 100%;
  min-width: 15rem;
  height: auto;
}

@container (min-width: 40rem) {
  .concepts-lead {
    grid-template-columns: minmax(0, 1fr) 16.25rem;
    align-items: start;
  }
}
