/* ===================================================================
   Pulse Browser Benchmark — CSS v1.1
   © 2024 Savic Labs. All rights reserved.
   
   Table of Contents:
   1. CSS Variables / Design Tokens
   2. Reset & Base
   3. Isolation Mode (.running)
   4. Layout
   5. Header
   6. Hero & Controls
   7. Segmented Controls
   8. System Badges
   9. Progress Section
   10. Results Section
   11. Validity Badge & Confidence Meter
   12. Advanced Panel
   13. Compare Section
   14. Aborted Section
   15. Footer
   16. Modal
   17. Buttons & Utilities
   18. Responsive
   =================================================================== */

/* -----------------------------------------------------------------
   1. CSS Variables / Design Tokens
   ----------------------------------------------------------------- */
:root {
  /* Colors - Dark Theme */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --bg-card: #16161f;
  --bg-elevated: #1e1e2a;
  
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --text-accent: #00d9ff;
  
  --accent-primary: #00d9ff;
  --accent-secondary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #00d9ff 0%, #7c3aed 100%);
  
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(0, 217, 255, 0.3);
  
  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 20px rgba(0, 217, 255, 0.15);
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  
  /* Layout */
  --header-height: 60px;
  --max-width: 720px;
}

/* -----------------------------------------------------------------
   2. Reset & Base
   ----------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input[type="file"] {
  display: none;
}

/* -----------------------------------------------------------------
   3. Isolation Mode (.running)
   CRITICAL: Disables all non-essential animations and transitions
   during benchmark execution to prevent interference.
   ----------------------------------------------------------------- */
body.running,
body.running *,
body.running *::before,
body.running *::after {
  animation: none !important;
  animation-duration: 0s !important;
  transition: none !important;
  transition-duration: 0s !important;
}

body.running .progress-bar {
  /* Exception: allow progress bar animation */
  transition: width 200ms linear !important;
}

body.running .benchmark-controls {
  pointer-events: none;
  opacity: 0.5;
}

body.running .header-status .status-pill {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

/* -----------------------------------------------------------------
   4. Layout
   ----------------------------------------------------------------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  padding-top: calc(var(--header-height) + var(--space-md));
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* -----------------------------------------------------------------
   5. Header
   ----------------------------------------------------------------- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-by {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-status {
  display: flex;
  align-items: center;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition-base);
}

.status-pill[data-status="ready"] {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.status-pill[data-status="running"] {
  background: var(--accent-primary);
  color: var(--bg-primary);
  box-shadow: var(--shadow-glow);
}

.status-pill[data-status="complete"] {
  background: var(--success);
  color: white;
}

.status-pill[data-status="aborted"] {
  background: var(--error);
  color: white;
}

/* -----------------------------------------------------------------
   6. Hero & Controls
   ----------------------------------------------------------------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-2xl) 0;
  min-height: 50vh;
}

.hero-content {
  width: 100%;
  max-width: 480px;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-sm);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.benchmark-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  transition: opacity var(--transition-base);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  align-items: center;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.url-params-hint {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.75rem;
  color: var(--accent-primary);
  background: rgba(0, 217, 255, 0.1);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.hero-secondary-actions {
  display: flex;
  gap: var(--space-sm);
}

/* -----------------------------------------------------------------
   7. Segmented Controls
   ----------------------------------------------------------------- */
.segmented-control {
  display: inline-flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.segment {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
  min-width: 60px;
}

.segment:hover:not(.active):not(:disabled) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.segment.active {
  background: var(--accent-primary);
  color: var(--bg-primary);
  font-weight: 600;
}

.segment:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* -----------------------------------------------------------------
   8. System Badges
   ----------------------------------------------------------------- */
.system-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.badge-icon {
  font-size: 0.875rem;
}

.badge-value {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

.badge-label {
  color: var(--text-muted);
}

/* -----------------------------------------------------------------
   9. Progress Section
   ----------------------------------------------------------------- */
.progress-section {
  padding: var(--space-xl) 0;
}

.progress-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-lg);
  text-align: center;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.progress-test-name {
  font-size: 1.125rem;
  font-weight: 600;
}

.progress-run-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.progress-bar-container {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  transition: width 200ms linear;
}

.progress-warning {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.wake-lock-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.toggle-label input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.toggle-label input:checked + .toggle-slider {
  background: var(--accent-primary);
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(16px);
  background: white;
}

.wake-lock-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* -----------------------------------------------------------------
   10. Results Section
   ----------------------------------------------------------------- */
.results-section {
  padding: var(--space-lg) 0;
}

.results-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-lg);
  overflow: hidden;
}

.results-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  min-width: 0; /* Enable flex children to shrink below content */
}

.results-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  flex-wrap: wrap;
  min-width: 0;
}

.results-header-main {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  min-width: 0;
}

.results-score-container {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.results-score-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.results-score {
  font-size: 3rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.results-stability {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  max-width: 50%;
}

.stability-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

/* Confidence container hardening for stress strings */
.confidence-container {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.results-categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.category-item {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.category-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.category-score {
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent-primary);
}

.category-bar-container {
  height: 6px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.category-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.results-environment {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-family: var(--font-mono);
  word-break: break-word;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
}

/* -----------------------------------------------------------------
   11. Validity Badge & Confidence Meter
   ----------------------------------------------------------------- */
.validity-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.validity-badge[data-valid="true"] {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.validity-badge[data-valid="false"] {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.confidence-meter {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.confidence-bar {
  width: 40px;
  min-width: 24px;
  height: 6px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.confidence-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-base), background var(--transition-base);
}

.confidence-meter[data-level="high"] .confidence-bar::after {
  width: 100%;
  background: var(--success);
}

.confidence-meter[data-level="medium"] .confidence-bar::after {
  width: 66%;
  background: var(--warning);
}

.confidence-meter[data-level="low"] .confidence-bar::after {
  width: 33%;
  background: var(--error);
}

.confidence-meter[data-level="unknown"] .confidence-bar::after {
  width: 0;
  background: var(--text-muted);
}

.confidence-label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* -----------------------------------------------------------------
   12. Advanced Panel
   ----------------------------------------------------------------- */
.advanced-panel {
  margin-top: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.advanced-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  list-style: none;
}

.advanced-panel-header::-webkit-details-marker {
  display: none;
}

.advanced-panel-header::after {
  content: '';
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform var(--transition-fast);
}

.advanced-panel[open] .advanced-panel-header::after {
  transform: rotate(180deg);
}

.advanced-panel-header:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.advanced-panel-content {
  padding: 0 var(--space-md) var(--space-md);
}

.advanced-section {
  margin-bottom: var(--space-lg);
}

.advanced-section:last-child {
  margin-bottom: 0;
}

.advanced-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}

.telemetry-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.telemetry-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.telemetry-value {
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  word-break: break-all;
}

/* Raw Runs Table */
.raw-runs-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.raw-runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.raw-runs-table th,
.raw-runs-table td {
  padding: var(--space-sm);
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
}

.raw-runs-table th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--bg-tertiary);
}

.raw-runs-table th:first-child,
.raw-runs-table td:first-child {
  text-align: left;
}

.raw-runs-table td {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.raw-runs-table td:first-child {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--text-primary);
}

.raw-runs-table tr:last-child td {
  border-bottom: none;
}

.raw-runs-table .cv-high {
  color: var(--error);
}

.raw-runs-table .cv-medium {
  color: var(--warning);
}

.raw-runs-table .cv-low {
  color: var(--success);
}

/* -----------------------------------------------------------------
   13. Compare Section
   ----------------------------------------------------------------- */
.compare-section {
  margin-top: var(--space-md);
}

.compare-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-accent);
  padding: var(--space-lg);
}

.compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.compare-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.compare-warnings {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  background: rgba(245, 158, 11, 0.1);
  border-radius: var(--radius-md);
}

.compare-warning-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.75rem;
  color: var(--warning);
}

.compare-warning-item::before {
  content: '⚠';
}

.compare-overall {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.compare-score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.compare-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.compare-score {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.compare-delta-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.compare-delta {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.compare-delta-pct {
  font-size: 0.875rem;
  font-family: var(--font-mono);
}

.compare-delta-box[data-direction="positive"] .compare-delta,
.compare-delta-box[data-direction="positive"] .compare-delta-pct {
  color: var(--success);
}

.compare-delta-box[data-direction="positive"] .compare-delta::before {
  content: '+';
}

.compare-delta-box[data-direction="negative"] .compare-delta,
.compare-delta-box[data-direction="negative"] .compare-delta-pct {
  color: var(--error);
}

.compare-delta-box[data-direction="neutral"] .compare-delta,
.compare-delta-box[data-direction="neutral"] .compare-delta-pct {
  color: var(--text-muted);
}

.compare-categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.compare-category-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.compare-category-name {
  font-weight: 500;
}

.compare-category-values {
  display: flex;
  gap: var(--space-md);
  font-family: var(--font-mono);
}

.compare-category-delta {
  min-width: 60px;
  text-align: right;
}

.compare-category-delta.positive {
  color: var(--success);
}

.compare-category-delta.negative {
  color: var(--error);
}

.compare-category-delta.neutral {
  color: var(--text-muted);
}

/* -----------------------------------------------------------------
   14. Aborted Section
   ----------------------------------------------------------------- */
.aborted-section {
  padding: var(--space-xl) 0;
}

.aborted-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: var(--space-2xl);
  text-align: center;
}

.aborted-icon {
  color: var(--error);
  margin-bottom: var(--space-md);
}

.aborted-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--error);
  margin-bottom: var(--space-sm);
}

.aborted-message {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto var(--space-lg);
}

/* -----------------------------------------------------------------
   15. Footer
   ----------------------------------------------------------------- */
.footer {
  padding: var(--space-lg) var(--space-md);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width);
  margin: 0 auto;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-brand a {
  color: var(--text-secondary);
}

.footer-version {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

/* -----------------------------------------------------------------
   16. Modal
   ----------------------------------------------------------------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-lg);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.modal-body {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-body p {
  margin-bottom: var(--space-md);
}

.profile-list {
  list-style: none;
  margin-bottom: var(--space-md);
}

.profile-list li {
  padding: var(--space-xs) 0;
  padding-left: var(--space-md);
  position: relative;
}

.profile-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent-primary);
}

.profile-note {
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--text-muted);
}

.modal-divider {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-md) 0;
}

.modal-close {
  width: 100%;
  margin-top: var(--space-md);
}

/* Share Modal */
.share-modal {
  z-index: 1001;
}

/* Safety: never show share modal during benchmark */
body.running .share-modal {
  display: none !important;
}

.share-modal-content {
  max-width: 360px;
  position: relative; /* For toast positioning */
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.modal-header .modal-title {
  margin-bottom: 0;
}

.modal-close-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.modal-close-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.share-score-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

.share-score-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.share-score-value {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.share-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

/* v1.1.2 Share Modal Sections */
.share-section {
  margin-bottom: var(--space-md);
}

.share-section:last-of-type {
  margin-bottom: 0;
}

.share-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.share-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

/* Base share button styles */
.share-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  min-height: 44px;
}

.share-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.share-btn:active {
  transform: scale(0.98);
}

.share-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.share-btn svg {
  flex-shrink: 0;
}

/* Primary action buttons - gradient accent */
.share-btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  color: white;
  font-weight: 600;
}

.share-btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.share-btn-primary:active {
  transform: translateY(0);
}

/* Icon-only platform buttons */
.share-platforms-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: flex-start;
}

.share-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.share-btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.share-btn-icon:active {
  transform: scale(0.95);
}

.share-btn-icon svg {
  flex-shrink: 0;
}

/* Validity badge in share preview */
.share-validity-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25em 0.75em;
  border-radius: 9999px;
  margin-top: var(--space-sm);
}

.share-validity-valid {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.share-validity-invalid {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

/* Toast notification */
.share-toast {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
  z-index: 10;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.share-toast-success {
  background: rgba(34, 197, 94, 0.95);
  color: white;
}

.share-toast-error {
  background: rgba(239, 68, 68, 0.95);
  color: white;
}

/* -----------------------------------------------------------------
   17. Buttons & Utilities
   ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--accent-gradient);
  color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-lg {
  font-size: 1rem;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-lg);
}

.btn-icon-svg {
  flex-shrink: 0;
}

/* -----------------------------------------------------------------
   18. Responsive
   ----------------------------------------------------------------- */

/* Hide GPU badge below 480px */
@media (max-width: 480px) {
  #badge-gpu-container {
    display: none !important;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 52px;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .benchmark-controls {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .control-group {
    width: 100%;
  }
  
  .segmented-control {
    width: 100%;
    justify-content: center;
  }
  
  .segment {
    flex: 1;
    min-width: unset;
  }
  
  .system-badges {
    gap: var(--space-xs);
  }
  
  .badge {
    font-size: 0.6875rem;
    padding: 3px 6px;
  }
  
  .results-score {
    font-size: 2.5rem;
  }
  
  /* Results header stacks vertically on mobile */
  .results-header-top {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .results-stability {
    align-items: flex-start;
  }
  
  .results-actions {
    flex-direction: column;
  }
  
  .results-actions .btn {
    width: 100%;
  }
  
  .compare-overall {
    flex-direction: column;
  }
  
  .compare-score-box {
    width: 100%;
  }
  
  .telemetry-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .raw-runs-table {
    font-size: 0.75rem;
  }
  
  .raw-runs-table th,
  .raw-runs-table td {
    padding: var(--space-xs);
  }
  
  /* Share modal adjustments */
  .share-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .share-btn {
    min-height: 64px;
    padding: var(--space-sm);
  }
}

@media (max-width: 360px) {
  .hero-title {
    font-size: 1.75rem;
  }
  
  .results-score {
    font-size: 2rem;
  }
  
  .segment {
    font-size: 0.75rem;
    padding: 4px 6px;
  }
  
  /* Harden results header for very small screens */
  .results-header-top {
    gap: var(--space-sm);
  }
  
  .results-stability {
    max-width: 45%;
  }
  
  /* Reduce confidence meter at very small sizes */
  .confidence-meter {
    min-width: 0;
    padding: var(--space-xs);
  }
  
  .confidence-bar {
    width: 24px;
  }
  
  .confidence-label {
    font-size: 0.6875rem;
    max-width: 50px;
  }
  
  /* Share modal for small screens */
  .share-row {
    gap: var(--space-xs);
  }
  
  .share-btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
    min-height: 40px;
  }
  
  .share-btn-primary span {
    display: none;
  }
  
  .share-btn-icon {
    width: 36px;
    height: 36px;
  }
}

/* Extreme minimum viewport (320px iPhone SE) */
@media (max-width: 320px) {
  .header-by {
    display: none;
  }
  
  /* Results header truncation */
  .results-stability {
    max-width: 40%;
  }
  
  .confidence-label {
    max-width: 40px;
  }
  
  .validity-badge {
    font-size: 0.5625rem;
    padding: 2px var(--space-xs);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .header,
  .hero-actions,
  .results-actions,
  .advanced-panel,
  .compare-section,
  .footer {
    display: none;
  }
  
  .main {
    padding-top: 0;
  }
  
  .results-card {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}
