/**
 * TrainersEye V5 — Base Stylesheet
 * Clinical-grade AI pose detection coaching tool
 * Mobile-first, dark-themed, mode-aware design system
 * Version: 5.0.0
 */

/* ============================================
   1. CSS CUSTOM PROPERTIES — DESIGN TOKENS
   ============================================ */

:root {
  /* --- Core Palette --- */
  --bg-primary: #0a0a0a;
  --bg-secondary: #0f0f0f;
  --surface: #141414;
  --surface-raised: #1a1a1a;
  --surface-highlight: #222222;
  --border-subtle: #1f1f1f;
  --border-default: #2a2a2a;
  --border-strong: #333333;
  --border-focus: #444444;

  /* --- Text Colors --- */
  --text-primary: #f0f0f0;
  --text-secondary: #999999;
  --text-tertiary: #666666;
  --text-disabled: #444444;
  --text-inverse: #0a0a0a;

  /* --- Mode-Agnostic Accent (defaults to general) --- */
  --accent: #4caf50;
  --accent-dim: rgba(76, 175, 80, 0.12);
  --accent-mid: rgba(76, 175, 80, 0.35);
  --accent-bright: rgba(76, 175, 80, 0.6);
  --accent-glow: rgba(76, 175, 80, 0.25);

  /* --- Semantic Colors --- */
  --good: #4caf50;
  --good-dim: rgba(76, 175, 80, 0.15);
  --good-glow: rgba(76, 175, 80, 0.3);
  --warn: #ff9800;
  --warn-dim: rgba(255, 152, 0, 0.15);
  --warn-glow: rgba(255, 152, 0, 0.3);
  --bad: #f44336;
  --bad-dim: rgba(244, 67, 54, 0.15);
  --bad-glow: rgba(244, 67, 54, 0.3);
  --info: #2196f3;
  --info-dim: rgba(33, 150, 243, 0.15);

  /* --- Score Gradient Scale --- */
  --score-excellent: #4caf50;
  --score-good: #8bc34a;
  --score-fair: #ffc107;
  --score-poor: #ff9800;
  --score-bad: #f44336;

  /* --- Typography --- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco,
    'Courier New', monospace;

  /* --- Type Scale --- */
  --text-3xs: 0.5625rem; /* 9px */
  --text-2xs: 0.625rem; /* 10px */
  --text-xs: 0.75rem; /* 12px */
  --text-sm: 0.875rem; /* 14px */
  --text-base: 1rem; /* 16px */
  --text-lg: 1.125rem; /* 18px */
  --text-xl: 1.25rem; /* 20px */
  --text-2xl: 1.5rem; /* 24px */
  --text-3xl: 1.875rem; /* 30px */
  --text-4xl: 2.25rem; /* 36px */
  --text-5xl: 3rem; /* 48px */

  /* --- Line Heights --- */
  --leading-none: 1;
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* --- Font Weights --- */
  --font-light: 300;
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-black: 900;

  /* --- Letter Spacing --- */
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  --tracking-widest: 0.1em;

  /* --- Spacing Scale --- */
  --space-px: 1px;
  --space-0: 0;
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem; /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem; /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem; /* 24px */
  --space-8: 2rem; /* 32px */
  --space-10: 2.5rem; /* 40px */
  --space-12: 3rem; /* 48px */
  --space-16: 4rem; /* 64px */
  --space-20: 5rem; /* 80px */

  /* --- Border Radius --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 0 20px var(--accent-glow);
  --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.3);

  /* --- Z-Index Scale --- */
  --z-base: 0;
  --z-elevated: 10;
  --z-sticky: 100;
  --z-header: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-toast: 600;
  --z-max: 9999;

  /* --- Transitions --- */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  --transition-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Layout --- */
  --topbar-height: 52px;
  --bottom-bar-height: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --header-blur: blur(20px) saturate(180%);
}

/* ============================================
   2. MODE-SPECIFIC COLOR VARIABLES
   ============================================ */

[data-mode='general'] {
  --accent: #4caf50;
  --accent-dim: rgba(76, 175, 80, 0.12);
  --accent-mid: rgba(76, 175, 80, 0.35);
  --accent-bright: rgba(76, 175, 80, 0.6);
  --accent-glow: rgba(76, 175, 80, 0.25);
}

[data-mode='coach'] {
  --accent: #ffc107;
  --accent-dim: rgba(255, 193, 7, 0.12);
  --accent-mid: rgba(255, 193, 7, 0.35);
  --accent-bright: rgba(255, 193, 7, 0.6);
  --accent-glow: rgba(255, 193, 7, 0.25);
}

[data-mode='pro'] {
  --accent: #00bcd4;
  --accent-dim: rgba(0, 188, 212, 0.12);
  --accent-mid: rgba(0, 188, 212, 0.35);
  --accent-bright: rgba(0, 188, 212, 0.6);
  --accent-glow: rgba(0, 188, 212, 0.25);
}

/* ============================================
   3. CSS RESET & NORMALIZE
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
  scroll-behavior: smooth;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100%;
  overflow: hidden;
  position: relative;
}

img,
video,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ============================================
   4. TYPOGRAPHY SYSTEM
   ============================================ */

/* --- Display / Hero --- */
.text-hero {
  font-size: var(--text-4xl);
  font-weight: var(--font-black);
  line-height: var(--leading-none);
  letter-spacing: var(--tracking-tight);
}

.text-display {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

/* --- Headings --- */
.text-h1 {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.text-h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

.text-h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

.text-h4 {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  color: var(--text-secondary);
}

/* --- Body --- */
.text-body {
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
}

.text-body-sm {
  font-size: var(--text-sm);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
}

/* --- Labels & Captions --- */
.text-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: var(--leading-none);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.text-caption {
  font-size: var(--text-xs);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--text-tertiary);
}

.text-micro {
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  line-height: var(--leading-none);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* --- Numbers / Data Readouts --- */
.text-number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.text-score {
  font-family: var(--font-mono);
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-none);
  letter-spacing: var(--tracking-tight);
}

.text-score-sm {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-none);
}

.text-metric {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-none);
}

/* --- Text Colors --- */
.text-primary {
  color: var(--text-primary);
}
.text-secondary {
  color: var(--text-secondary);
}
.text-tertiary {
  color: var(--text-tertiary);
}
.text-disabled {
  color: var(--text-disabled);
}
.text-accent {
  color: var(--accent);
}
.text-good {
  color: var(--good);
}
.text-warn {
  color: var(--warn);
}
.text-bad {
  color: var(--bad);
}
.text-info {
  color: var(--info);
}

/* --- Font Weights --- */
.font-light {
  font-weight: var(--font-light);
}
.font-regular {
  font-weight: var(--font-regular);
}
.font-medium {
  font-weight: var(--font-medium);
}
.font-semibold {
  font-weight: var(--font-semibold);
}
.font-bold {
  font-weight: var(--font-bold);
}

/* ============================================
   5. BUTTON STYLES
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: var(--leading-none);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  min-height: 44px;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.btn:active::after {
  opacity: 1;
}

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

.btn:disabled {
  opacity: 0.4;
  transform: none;
  pointer-events: none;
}

/* --- Button Variants --- */

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px var(--accent-glow);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-highlight);
  border-color: var(--border-strong);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--bad);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--bad-glow);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 4px 16px var(--bad-glow);
  filter: brightness(1.1);
}

/* --- Mode-Select Button --- */
.btn-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--border-default);
  color: var(--text-secondary);
  transition: all var(--transition-base);
  min-height: 44px;
  flex: 1;
}

.btn-mode:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-mode.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* --- Icon Button --- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-size: var(--text-lg);
}

.btn-icon:hover {
  background: var(--surface-highlight);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-icon:active {
  transform: scale(0.92);
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  min-height: 32px;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.btn-icon-lg {
  width: 52px;
  height: 52px;
  min-height: 52px;
  font-size: var(--text-xl);
  border-radius: var(--radius-lg);
}

/* --- Floating Action Button --- */
.btn-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 4px 16px var(--accent-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
  font-size: var(--text-xl);
  transition: all var(--transition-base);
}

.btn-fab:hover {
  box-shadow: 0 6px 24px var(--accent-glow), 0 4px 12px rgba(0, 0, 0, 0.5);
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-fab:active {
  transform: scale(0.95) translateY(0);
}

/* --- Button Sizes --- */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  min-height: 32px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  min-height: 52px;
  border-radius: var(--radius-lg);
}

/* ============================================
   6. FORM CONTROLS
   ============================================ */

/* --- Select Dropdown --- */
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding: var(--space-3) var(--space-10) var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  background-color: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  min-height: 44px;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.select:hover {
  border-color: var(--border-strong);
}

.select option {
  background: var(--surface-raised);
  color: var(--text-primary);
}

/* --- Text Input --- */
.input {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  min-height: 44px;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input::placeholder {
  color: var(--text-tertiary);
}

/* --- Toggle Switch --- */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: var(--space-3);
}

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

.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--surface-highlight);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  transition: background var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: transform var(--transition-fast), background var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle-input:checked + .toggle-track {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
  background: var(--accent);
}

.toggle-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.toggle-input:checked ~ .toggle-label {
  color: var(--text-primary);
}

/* ============================================
   7. STATUS INDICATORS
   ============================================ */

/* --- Status Dot --- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--text-tertiary);
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: var(--radius-full);
  border: 1.5px solid currentColor;
  opacity: 0;
  animation: statusPulse 2s ease-in-out infinite;
}

.status-dot.active {
  background: var(--good);
  color: var(--good);
}

.status-dot.active::after {
  opacity: 1;
}

.status-dot.warning {
  background: var(--warn);
  color: var(--warn);
}

.status-dot.error {
  background: var(--bad);
  color: var(--bad);
}

.status-dot.processing {
  background: var(--accent);
  color: var(--accent);
}

/* --- Status Pill --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pill-default {
  background: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.pill-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-mid);
}

.pill-good {
  background: var(--good-dim);
  color: var(--good);
  border: 1px solid var(--good-glow);
}

.pill-warn {
  background: var(--warn-dim);
  color: var(--warn);
  border: 1px solid var(--warn-glow);
}

.pill-bad {
  background: var(--bad-dim);
  color: var(--bad);
  border: 1px solid var(--bad-glow);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-2);
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-inverse);
}

/* --- Score Ring --- */
.score-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
}

.score-ring svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: var(--surface-highlight);
  stroke-width: 6;
}

.score-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
}

.score-ring-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

/* ============================================
   8. SCORE COLORS & ANIMATIONS
   ============================================ */

.score-excellent {
  color: var(--score-excellent);
}
.score-good {
  color: var(--score-good);
}
.score-fair {
  color: var(--score-fair);
}
.score-poor {
  color: var(--score-poor);
}
.score-bad {
  color: var(--score-bad);
}

/* Score background variants */
.score-bg-excellent {
  background: var(--good-dim);
  color: var(--score-excellent);
}
.score-bg-good {
  background: rgba(139, 195, 74, 0.15);
  color: var(--score-good);
}
.score-bg-fair {
  background: rgba(255, 193, 7, 0.15);
  color: var(--score-fair);
}
.score-bg-poor {
  background: var(--warn-dim);
  color: var(--score-poor);
}
.score-bg-bad {
  background: var(--bad-dim);
  color: var(--score-bad);
}

/* Score flash animation */
@keyframes scoreFlash {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

.score-flash {
  animation: scoreFlash 300ms var(--transition-bounce);
}

/* Score counter animation */
@keyframes scoreCountUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.score-count-up {
  animation: scoreCountUp 400ms ease-out;
}

/* ============================================
   9. SCROLLBAR STYLING
   ============================================ */

/* Webkit */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

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

/* ============================================
   10. UTILITY CLASSES
   ============================================ */

/* --- Display --- */
.hidden {
  display: none !important;
}
.invisible {
  visibility: hidden;
}
.block {
  display: block;
}
.inline-block {
  display: inline-block;
}

/* --- Flex --- */
.flex {
  display: flex;
}
.inline-flex {
  display: inline-flex;
}
.flex-col {
  flex-direction: column;
}
.flex-row {
  flex-direction: row;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-nowrap {
  flex-wrap: nowrap;
}
.flex-1 {
  flex: 1 1 0%;
}
.flex-shrink-0 {
  flex-shrink: 0;
}
.flex-grow {
  flex-grow: 1;
}

/* --- Alignment --- */
.items-start {
  align-items: flex-start;
}
.items-center {
  align-items: center;
}
.items-end {
  align-items: flex-end;
}
.items-stretch {
  align-items: stretch;
}
.justify-start {
  justify-content: flex-start;
}
.justify-center {
  justify-content: center;
}
.justify-end {
  justify-content: flex-end;
}
.justify-between {
  justify-content: space-between;
}
.justify-around {
  justify-content: space-around;
}

/* --- Grid --- */
.grid {
  display: grid;
}
.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.gap-1 {
  gap: var(--space-1);
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.gap-4 {
  gap: var(--space-4);
}
.gap-6 {
  gap: var(--space-6);
}

/* --- Spacing --- */
.p-0 {
  padding: 0;
}
.p-2 {
  padding: var(--space-2);
}
.p-3 {
  padding: var(--space-3);
}
.p-4 {
  padding: var(--space-4);
}
.p-6 {
  padding: var(--space-6);
}

.px-3 {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
.px-4 {
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}
.py-2 {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}
.py-3 {
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

.m-0 {
  margin: 0;
}
.m-auto {
  margin: auto;
}

/* --- Sizing --- */
.w-full {
  width: 100%;
}
.h-full {
  height: 100%;
}
.min-h-0 {
  min-height: 0;
}
.min-w-0 {
  min-width: 0;
}

/* --- Overflow --- */
.overflow-hidden {
  overflow: hidden;
}
.overflow-auto {
  overflow: auto;
}
.overflow-x-auto {
  overflow-x: auto;
}
.overflow-y-auto {
  overflow-y: auto;
}

/* --- Position --- */
.relative {
  position: relative;
}
.absolute {
  position: absolute;
}
.fixed {
  position: fixed;
}
.inset-0 {
  inset: 0;
}

/* --- Borders --- */
.border {
  border: 1px solid var(--border-default);
}
.border-subtle {
  border-color: var(--border-subtle);
}
.border-strong {
  border-color: var(--border-strong);
}
.rounded-sm {
  border-radius: var(--radius-sm);
}
.rounded-md {
  border-radius: var(--radius-md);
}
.rounded-lg {
  border-radius: var(--radius-lg);
}
.rounded-full {
  border-radius: var(--radius-full);
}

/* --- Background --- */
.bg-primary {
  background: var(--bg-primary);
}
.bg-surface {
  background: var(--surface);
}
.bg-surface-raised {
  background: var(--surface-raised);
}
.bg-accent-dim {
  background: var(--accent-dim);
}

/* --- Text Alignment --- */
.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}

/* --- Pointer Events --- */
.pointer-events-none {
  pointer-events: none;
}
.pointer-events-auto {
  pointer-events: auto;
}

/* --- Touch --- */
.touch-none {
  touch-action: none;
}
.touch-manipulation {
  touch-action: manipulation;
}

/* ============================================
   11. CARD / PANEL COMPONENTS
   ============================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--border-default);
}

.card-raised {
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 44px;
}

.panel-body {
  padding: var(--space-4);
}

/* ============================================
   12. DIVIDERS
   ============================================ */

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-3) 0;
}

.divider-vertical {
  width: 1px;
  background: var(--border-subtle);
  align-self: stretch;
  margin: 0 var(--space-3);
}

/* ============================================
   13. LISTS
   ============================================ */

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  min-height: 48px;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:active {
  background: var(--surface-raised);
}

/* ============================================
   14. ANIMATION KEYFRAMES
   ============================================ */

/* --- Fade --- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Slide --- */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* --- Pulse --- */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes statusPulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  70% {
    transform: scale(2);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    box-shadow: 0 0 4px var(--accent-glow);
  }
  50% {
    box-shadow: 0 0 16px var(--accent-glow);
  }
}

/* --- Pop / Bounce --- */
@keyframes popIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

/* --- Shake --- */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

/* --- Spin --- */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* --- Skeleton --- */
@keyframes skeleton {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 25%,
    var(--surface-raised) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* --- Cue Flash --- */
@keyframes cueFlash {
  0% {
    background: transparent;
  }
  20% {
    background: var(--accent-dim);
  }
  100% {
    background: transparent;
  }
}

/* --- Scanline (camera overlay effect) --- */
@keyframes scanline {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100vh);
  }
}

/* ============================================
   15. ANIMATION UTILITY CLASSES
   ============================================ */

.anim-fade-in {
  animation: fadeIn 250ms ease forwards;
}
.anim-fade-in-up {
  animation: fadeInUp 350ms ease forwards;
}
.anim-fade-in-down {
  animation: fadeInDown 350ms ease forwards;
}
.anim-fade-in-scale {
  animation: fadeInScale 300ms ease forwards;
}
.anim-slide-in-right {
  animation: slideInRight 350ms ease forwards;
}
.anim-slide-in-left {
  animation: slideInLeft 350ms ease forwards;
}
.anim-slide-in-up {
  animation: slideInUp 400ms ease forwards;
}
.anim-pop-in {
  animation: popIn 400ms var(--transition-bounce) forwards;
}
.anim-pop {
  animation: pop 300ms var(--transition-bounce);
}
.anim-pulse {
  animation: pulse 2s ease-in-out infinite;
}
.anim-pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}
.anim-shake {
  animation: shake 400ms ease-in-out;
}
.anim-spin {
  animation: spin 1s linear infinite;
}

/* Stagger delays */
.stagger-1 {
  animation-delay: 50ms;
}
.stagger-2 {
  animation-delay: 100ms;
}
.stagger-3 {
  animation-delay: 150ms;
}
.stagger-4 {
  animation-delay: 200ms;
}
.stagger-5 {
  animation-delay: 250ms;
}

/* ============================================
   16. MODE TRANSITION ANIMATIONS
   ============================================ */

.mode-transition {
  transition: background-color var(--transition-slow), border-color var(--transition-slow),
    color var(--transition-slow), box-shadow var(--transition-slow);
}

.mode-transition-accent {
  transition: stroke 0.4s ease, background-color 0.4s ease, border-color 0.4s ease,
    color 0.4s ease, box-shadow 0.4s ease;
}

/* Mode switch flash overlay */
.mode-flash-overlay {
  position: fixed;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: var(--z-max);
  transition: opacity 0.3s ease;
}

.mode-flash-overlay.active {
  animation: modeFlash 500ms ease forwards;
}

@keyframes modeFlash {
  0% {
    opacity: 0.15;
  }
  100% {
    opacity: 0;
  }
}

/* ============================================
   17. ACCESSIBILITY
   ============================================ */

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================
   18. PRINT STYLES
   ============================================ */

@media print {
  body {
    background: white;
    color: black;
  }
  .no-print {
    display: none !important;
  }
}
