/**
 * TrainersEye V5 — Mobile-First Responsive Stylesheet
 * PRIMARY USAGE: Mobile devices (phone/tablet)
 * Desktop enhancements in layout.css
 * Version: 5.0.0
 */

/* ============================================
   1. MOBILE APP SHELL (Base: <= 1023px)
   ============================================ */

@media (max-width: 1023px) {
  .app-shell {
    position: fixed;
    inset: 0;
    overflow: hidden;
  }

  /* --- Single Column Layout --- */
  .main-layout {
    flex-direction: column;
    overflow: hidden;
  }

  /* --- Camera Panel: Top ~60% --- */
  .camera-panel {
    flex: 0 0 55vh;
    flex-direction: column;
    min-height: 0;
    position: relative;
  }

  /* --- Side Panel becomes Bottom Controls --- */
  .side-panel {
    flex: 1;
    min-height: 0;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    max-width: none;
  }

  .side-panel-scroll {
    padding: var(--space-3);
    gap: var(--space-3);
  }
}

/* ============================================
   2. MOBILE TOPBAR
   ============================================ */

@media (max-width: 1023px) {
  .topbar {
    height: 48px;
    min-height: 48px;
    padding: 0 var(--space-3);
    gap: var(--space-2);
  }

  .logo-text {
    font-size: var(--text-base);
  }

  .logo-badge {
    display: none;
  }

  /* Hide desktop topbar controls - shown in side panel instead */
  .topbar-mode-selector,
  .topbar-voice,
  .camera-status-label {
    display: none;
  }

  .camera-status {
    gap: var(--space-1);
  }

  /* Compact topbar status dot */
  .camera-status .status-dot {
    width: 7px;
    height: 7px;
  }
}

/* ============================================
   3. MOBILE CAMERA STAGE
   ============================================ */

@media (max-width: 1023px) {
  .camera-stage {
    flex: 1;
    min-height: 0;
  }

  /* Smaller corner brackets */
  .camera-brackets {
    inset: var(--space-2);
  }

  .camera-brackets::before,
  .camera-brackets::after,
  .camera-brackets-bottom::before,
  .camera-brackets-bottom::after {
    width: 16px;
    height: 16px;
  }

  /* Hide scanline on mobile for performance */
  .camera-scanline::after {
    animation-duration: 4s;
    opacity: 0.2;
  }

  /* Hide grid on mobile */
  .camera-grid {
    display: none;
  }
}

/* ============================================
   4. MOBILE HUD OVERLAY (Simplified)
   ============================================ */

@media (max-width: 1023px) {
  .hud-overlay {
    padding: var(--space-3);
  }

  /* --- Simplified HUD Top --- */
  .hud-top {
    gap: var(--space-2);
  }

  .hud-exercise-name {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
  }

  .hud-exercise-sub {
    font-size: var(--text-3xs);
  }

  /* Score badge: larger, more prominent */
  .hud-score-badge {
    padding: var(--space-1) var(--space-3);
    gap: var(--space-1);
  }

  .hud-score-value {
    font-size: var(--text-xl);
  }

  .hud-score-label {
    font-size: var(--text-3xs);
  }

  /* Mode badge: compact */
  .hud-mode-badge {
    padding: 2px var(--space-2);
    font-size: var(--text-3xs);
  }

  /* Voice indicator: hidden on HUD (use control panel instead) */
  .hud-voice-indicator {
    display: none;
  }

  /* --- HUD Cue Bar: Full Width, Prominent --- */
  .hud-bottom {
    width: 100%;
    max-width: none;
    padding: 0 var(--space-1);
    gap: var(--space-2);
  }

  .hud-cue-bar {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
  }

  .hud-cue-text {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
  }

  .hud-cue-sub {
    font-size: var(--text-3xs);
    margin-top: 2px;
  }

  /* --- Angle Readout: Hidden on mobile (show in panel) --- */
  .hud-angle-readout {
    display: none;
  }
}

/* ============================================
   5. MOBILE SIDE PANEL (Bottom Controls)
   ============================================ */

@media (max-width: 1023px) {
  /* --- Section Spacing --- */
  .side-panel .section-header {
    margin-bottom: var(--space-2);
  }

  .side-panel .section-title {
    font-size: var(--text-3xs);
  }

  /* --- Mode Selector: Horizontal Scroll --- */
  .mode-cards {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-1);
    scrollbar-width: none;
  }

  .mode-cards::-webkit-scrollbar {
    display: none;
  }

  .mode-card {
    flex: 0 0 calc(33.333% - var(--space-1));
    min-width: 100px;
    scroll-snap-align: start;
    padding: var(--space-3) var(--space-2);
  }

  .mode-card-icon {
    width: 32px;
    height: 32px;
    font-size: var(--text-base);
  }

  .mode-card-label {
    font-size: var(--text-3xs);
  }

  /* --- Exercise Selector --- */
  .exercise-select-row {
    flex-direction: column;
  }

  .exercise-select-row .select {
    min-height: 44px;
    font-size: var(--text-base);
  }

  /* --- Voice Options --- */
  .voice-options {
    gap: var(--space-2);
  }

  .voice-option {
    min-height: 48px;
    font-size: var(--text-base);
  }

  /* --- Stats Grid: Horizontal Scroll Cards --- */
  .stats-grid {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--space-1);
  }

  .stats-grid::-webkit-scrollbar {
    display: none;
  }

  .stat-card {
    flex: 0 0 calc(33.333% - var(--space-1));
    min-width: 90px;
    scroll-snap-align: start;
    padding: var(--space-3) var(--space-2);
  }

  .stat-value {
    font-size: var(--text-lg);
  }

  .stat-label {
    font-size: var(--text-3xs);
  }

  /* --- Controls Row --- */
  .controls-row {
    gap: var(--space-2);
  }

  .controls-row .btn {
    min-height: 48px;
    font-size: var(--text-base);
    border-radius: var(--radius-md);
  }

  /* --- Camera Controls --- */
  .camera-controls {
    gap: var(--space-2);
  }

  .camera-controls .btn {
    min-height: 44px;
  }

  /* --- Calibration Card --- */
  .calibration-card {
    padding: var(--space-3);
    gap: var(--space-2);
  }

  .calibration-status-icon {
    width: 36px;
    height: 36px;
    font-size: var(--text-base);
  }

  .calibration-status-title {
    font-size: var(--text-xs);
  }

  .calibration-status-desc {
    font-size: var(--text-3xs);
  }

  /* --- Feedback List --- */
  .feedback-list {
    max-height: 140px;
  }

  .feedback-item {
    padding: var(--space-2) var(--space-3);
    min-height: 40px;
  }

  .feedback-item-text {
    font-size: var(--text-2xs);
  }

  /* --- Session Log --- */
  .session-log {
    max-height: 120px;
  }

  .log-entry {
    font-size: var(--text-3xs);
  }
}

/* ============================================
   6. BOTTOM SHEET (Mobile Controls)
   ============================================ */

@media (max-width: 1023px) {
  .bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fadeIn 200ms ease forwards;
  }

  .bottom-sheet {
    max-height: 75vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .bottom-sheet-handle {
    width: 36px;
    height: 3px;
    margin: var(--space-2) auto var(--space-1);
  }

  .bottom-sheet-header {
    padding: var(--space-3) var(--space-4) var(--space-3);
  }

  .bottom-sheet-title {
    font-size: var(--text-base);
  }

  .bottom-sheet-body {
    padding: 0 var(--space-4) var(--space-4);
  }

  .bottom-sheet-footer {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
  }

  .bottom-sheet-footer .btn {
    min-height: 48px;
    font-size: var(--text-base);
  }

  /* Bottom sheet sections */
  .bottom-sheet-section {
    margin-bottom: var(--space-4);
  }

  .bottom-sheet-section-title {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-subtle);
  }
}

/* ============================================
   7. BOTTOM TAB BAR (Mobile Mode Selector)
   ============================================ */

@media (max-width: 1023px) {
  .bottom-tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--bottom-bar-height);
    min-height: var(--bottom-bar-height);
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: var(--header-blur);
    -webkit-backdrop-filter: var(--header-blur);
    border-top: 1px solid var(--border-subtle);
    padding: 0 var(--space-2);
    padding-bottom: max(var(--space-1), var(--safe-bottom));
    position: relative;
    z-index: var(--z-header);
    flex-shrink: 0;
  }

  .bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    transition: color var(--transition-fast);
    position: relative;
    min-height: 44px;
  }

  .bottom-tab::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 var(--radius-full) var(--radius-full);
    opacity: 0;
    transition: opacity var(--transition-fast);
  }

  .bottom-tab.active {
    color: var(--accent);
  }

  .bottom-tab.active::after {
    opacity: 1;
  }

  .bottom-tab-icon {
    font-size: var(--text-xl);
    line-height: 1;
  }

  .bottom-tab-label {
    font-size: var(--text-3xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    line-height: 1;
  }
}

/* Hide bottom tab bar on desktop */
@media (min-width: 1024px) {
  .bottom-tab-bar {
    display: none;
  }
}

/* ============================================
   8. FLOATING ACTION BUTTON (Mobile)
   ============================================ */

@media (max-width: 1023px) {
  .fab-container {
    position: fixed;
    bottom: calc(var(--bottom-bar-height) + var(--space-4) + var(--safe-bottom));
    right: var(--space-4);
    z-index: var(--z-elevated);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: flex-end;
  }

  .btn-fab {
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 16px var(--accent-glow), 0 4px 12px rgba(0, 0, 0, 0.5);
  }

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

  .btn-fab-secondary:hover {
    background: var(--surface-highlight);
    color: var(--text-primary);
  }

  /* FAB with label (extended FAB) */
  .btn-fab-extended {
    width: auto;
    padding: 0 var(--space-5);
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
  }
}

/* Hide FAB container on desktop */
@media (min-width: 1024px) {
  .fab-container {
    display: none;
  }
}

/* ============================================
   9. TOUCH OPTIMIZATION
   ============================================ */

@media (max-width: 1023px) {
  /* Minimum touch targets */
  .btn,
  .btn-icon,
  .select,
  .input,
  .toggle,
  .mode-card,
  .voice-option,
  .list-item,
  .btn-mode,
  .voice-toggle-btn,
  .topbar-mode-btn {
    min-height: 44px;
  }

  .btn-sm,
  .btn-icon-sm {
    min-height: 36px;
  }

  /* Active touch feedback */
  .btn:active,
  .btn-icon:active,
  .mode-card:active,
  .voice-option:active,
  .list-item:active,
  .btn-mode:active {
    transform: scale(0.97);
    opacity: 0.9;
  }

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

  /* Remove hover effects on touch devices */
  @media (hover: none) {
    .btn:hover,
    .btn-icon:hover,
    .btn-mode:hover,
    .mode-card:hover,
    .voice-option:hover,
    .topbar-mode-btn:hover,
    .voice-toggle-btn:hover {
      background: initial;
      border-color: initial;
      color: initial;
      filter: none;
      box-shadow: initial;
    }

    .btn-primary:active {
      filter: brightness(1.1);
    }

    .btn-secondary:active {
      background: var(--surface-highlight);
    }
  }
}

/* ============================================
   10. MOBILE TYPOGRAPHY (Larger for readability)
   ============================================ */

@media (max-width: 1023px) {
  body {
    font-size: var(--text-base);
  }

  .text-hero {
    font-size: var(--text-3xl);
  }

  .text-display {
    font-size: var(--text-2xl);
  }

  .text-h1 {
    font-size: var(--text-xl);
  }

  .text-h2 {
    font-size: var(--text-lg);
  }

  .text-h3 {
    font-size: var(--text-base);
  }

  .text-body {
    font-size: var(--text-base);
  }

  .text-body-sm {
    font-size: var(--text-sm);
  }

  .text-label,
  .text-caption {
    font-size: var(--text-xs);
  }

  .text-micro {
    font-size: var(--text-3xs);
  }

  .text-score {
    font-size: var(--text-3xl);
  }

  .text-score-sm {
    font-size: var(--text-xl);
  }

  .text-metric {
    font-size: var(--text-lg);
  }
}

/* ============================================
   11. REDUCED PADDING / SPACING ON MOBILE
   ============================================ */

@media (max-width: 1023px) {
  :root {
    --topbar-height: 48px;
  }

  .card,
  .card-raised {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

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

  .panel-header {
    padding: var(--space-2) var(--space-3);
  }
}

/* ============================================
   12. PREVENT TEXT SELECTION DURING EXERCISE
   ============================================ */

@media (max-width: 1023px) {
  .app-shell.exercising,
  .app-shell.exercising * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
  }

  .app-shell.exercising .btn,
  .app-shell.exercising .btn-icon {
    touch-action: manipulation;
  }
}

/* ============================================
   13. SAFE AREA HANDLING
   ============================================ */

@media (max-width: 1023px) {
  /* iOS safe areas */
  .app-shell {
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }

  .topbar {
    padding-top: max(var(--space-2), var(--safe-top));
    height: calc(48px + var(--safe-top));
    min-height: calc(48px + var(--safe-top));
  }

  .bottom-tab-bar {
    padding-bottom: max(var(--space-2), var(--safe-bottom));
    height: calc(var(--bottom-bar-height) + var(--safe-bottom));
  }

  /* Notch area handling */
  @supports (padding-top: env(safe-area-inset-top)) {
    .hud-top {
      padding-top: max(var(--space-3), env(safe-area-inset-top));
    }
  }
}

/* ============================================
   14. LANDSCAPE ORIENTATION (Mobile)
   ============================================ */

@media (max-width: 1023px) and (orientation: landscape) {
  /* Horizontal layout: Camera left, controls right */
  .main-layout {
    flex-direction: row;
  }

  .camera-panel {
    flex: 1 1 65%;
    height: 100%;
  }

  .side-panel {
    flex: 0 0 35%;
    max-width: 280px;
    border-left: 1px solid var(--border-subtle);
    border-top: none;
  }

  /* Compact topbar */
  .topbar {
    height: 40px;
    min-height: 40px;
    padding-top: var(--space-1);
  }

  /* Hide bottom tab bar in landscape */
  .bottom-tab-bar {
    display: none;
  }

  /* Reposition FAB */
  .fab-container {
    bottom: calc(var(--space-4) + var(--safe-bottom));
  }

  /* Compact HUD */
  .hud-overlay {
    padding: var(--space-2);
  }

  .hud-exercise-name {
    font-size: var(--text-sm);
  }

  .hud-score-badge {
    padding: var(--space-1) var(--space-2);
  }

  .hud-score-value {
    font-size: var(--text-lg);
  }

  .hud-cue-bar {
    padding: var(--space-2) var(--space-3);
  }

  .hud-cue-text {
    font-size: var(--text-sm);
  }

  /* Compact side panel in landscape */
  .side-panel-scroll {
    padding: var(--space-2);
    gap: var(--space-2);
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-1);
    overflow-x: visible;
  }

  .stat-card {
    flex: none;
    min-width: 0;
    scroll-snap-align: none;
    padding: var(--space-2);
  }

  .stat-value {
    font-size: var(--text-base);
  }

  .controls-row .btn {
    min-height: 40px;
    font-size: var(--text-xs);
  }
}

/* ============================================
   15. SMALL PHONES (<= 380px)
   ============================================ */

@media (max-width: 380px) {
  .topbar {
    padding: 0 var(--space-2);
    height: 44px;
    min-height: 44px;
  }

  .logo-text {
    font-size: var(--text-sm);
  }

  .camera-panel {
    flex: 0 0 50vh;
  }

  .side-panel-scroll {
    padding: var(--space-2);
    gap: var(--space-2);
  }

  .mode-card {
    flex: 0 0 calc(33.333% - var(--space-1));
    min-width: 85px;
    padding: var(--space-2) var(--space-1);
  }

  .mode-card-icon {
    width: 28px;
    height: 28px;
    font-size: var(--text-sm);
  }

  .stat-card {
    min-width: 75px;
    padding: var(--space-2) var(--space-1);
  }

  .stat-value {
    font-size: var(--text-base);
  }

  .controls-row .btn {
    min-height: 44px;
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
  }

  .btn-fab {
    width: 48px;
    height: 48px;
    font-size: var(--text-lg);
  }

  .hud-cue-text {
    font-size: var(--text-sm);
  }

  .feedback-item {
    padding: var(--space-1) var(--space-2);
    min-height: 36px;
  }

  .feedback-item-text {
    font-size: var(--text-3xs);
  }
}

/* ============================================
   16. TABLET ADJUSTMENTS (768px - 1023px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1023px) {
  .camera-panel {
    flex: 0 0 60vh;
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
  }

  .stat-card {
    flex: none;
    min-width: 0;
    scroll-snap-align: none;
  }

  .mode-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
  }

  .mode-card {
    flex: none;
    min-width: 0;
    scroll-snap-align: none;
  }

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

/* ============================================
   17. MOBILE MODAL / BOTTOM SHEET ENHANCEMENTS
   ============================================ */

@media (max-width: 1023px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none;
    width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border: none;
    border-bottom: none;
    animation: slideInUp 300ms ease forwards;
  }

  .modal-header {
    padding: var(--space-4) var(--space-5) var(--space-3);
  }

  .modal-title {
    font-size: var(--text-base);
  }

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

  .modal-footer {
    padding: var(--space-3) var(--space-5);
    flex-direction: column;
    gap: var(--space-2);
  }

  .modal-footer .btn {
    width: 100%;
    min-height: 48px;
  }

  /* Full-screen overlays on mobile */
  .overlay-screen {
    padding: var(--space-4);
  }

  .overlay-content {
    padding: var(--space-6);
    gap: var(--space-5);
  }

  .overlay-icon {
    width: 64px;
    height: 64px;
    font-size: var(--text-2xl);
  }

  .overlay-title {
    font-size: var(--text-xl);
  }

  .overlay-subtitle {
    font-size: var(--text-sm);
  }

  .overlay-actions {
    flex-direction: column;
    gap: var(--space-2);
  }

  .overlay-actions .btn {
    width: 100%;
    min-height: 48px;
  }
}

/* ============================================
   18. MOBILE TOAST NOTIFICATIONS
   ============================================ */

@media (max-width: 1023px) {
  .toast-container {
    top: calc(var(--topbar-height) + var(--space-2));
    right: var(--space-3);
    left: var(--space-3);
  }

  .toast {
    max-width: none;
    width: 100%;
    animation: fadeInUp 250ms ease forwards;
  }
}

/* ============================================
   19. SCORE DISPLAY (Mobile Medical Readout)
   ============================================ */

@media (max-width: 1023px) {
  .score-readout {
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
  }

  .score-readout-value {
    font-family: var(--font-mono);
    font-size: var(--text-5xl);
    font-weight: var(--font-bold);
    line-height: var(--leading-none);
    letter-spacing: var(--tracking-tight);
    color: var(--accent);
    transition: color var(--transition-base);
  }

  .score-readout-max {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
  }

  .score-readout-label {
    font-size: var(--text-3xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-top: var(--space-1);
  }

  /* Compact score for HUD */
  .score-readout.compact .score-readout-value {
    font-size: var(--text-3xl);
  }

  .score-readout.compact .score-readout-max {
    font-size: var(--text-xs);
  }
}

/* ============================================
   20. EXERCISE TIMER / REP COUNTER (Mobile)
   ============================================ */

@media (max-width: 1023px) {
  .rep-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    font-family: var(--font-mono);
  }

  .rep-counter-value {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    line-height: var(--leading-none);
    min-width: 2ch;
    text-align: center;
  }

  .rep-counter-label {
    font-size: var(--text-3xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
  }

  .timer-display {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    line-height: var(--leading-none);
    letter-spacing: var(--tracking-wide);
    font-variant-numeric: tabular-nums;
  }

  .timer-display.running {
    color: var(--accent);
  }
}

/* ============================================
   21. PROGRESS INDICATORS (Mobile)
   ============================================ */

@media (max-width: 1023px) {
  /* Circular progress for mobile */
  .progress-ring-sm {
    width: 48px;
    height: 48px;
  }

  .progress-ring-sm .score-ring-value {
    font-size: var(--text-sm);
  }

  /* Linear progress bar */
  .progress-bar {
    height: 4px;
    background: var(--surface-raised);
    border-radius: var(--radius-full);
    overflow: hidden;
  }

  .progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
  }

  .progress-bar-fill.good {
    background: var(--good);
  }

  .progress-bar-fill.warn {
    background: var(--warn);
  }

  .progress-bar-fill.bad {
    background: var(--bad);
  }

  /* Phase indicator */
  .phase-indicator {
    display: flex;
    gap: 3px;
    align-items: center;
  }

  .phase-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--surface-highlight);
    transition: all var(--transition-base);
  }

  .phase-dot.active {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
  }

  .phase-dot.completed {
    background: var(--accent-mid);
  }
}

/* ============================================
   22. PULL-DOWN SETTINGS PANEL
   ============================================ */

@media (max-width: 1023px) {
  .pull-down-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2);
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
  }

  .pull-down-indicator.pulling {
    transform: rotate(180deg);
  }

  .settings-panel {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: var(--header-blur);
    -webkit-backdrop-filter: var(--header-blur);
    border-bottom: 1px solid var(--border-subtle);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
  }

  .settings-panel.open {
    max-height: 60vh;
    overflow-y: auto;
  }

  .settings-panel-content {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .settings-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .settings-group-label {
    font-size: var(--text-3xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
  }

  .settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-height: 48px;
  }

  .settings-option-label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
  }
}

/* ============================================
   23. DESKTOP ENHANCEMENTS (>= 1024px)
   ============================================ */

@media (min-width: 1024px) {
  /* Restore side panel */
  .side-panel {
    display: flex !important;
  }

  /* Hide mobile-only elements */
  .bottom-tab-bar,
  .fab-container,
  .pull-down-indicator,
  .settings-panel {
    display: none !important;
  }
}

/* ============================================
   24. VERY LARGE SCREENS (>= 1600px)
   ============================================ */

@media (min-width: 1600px) {
  .side-panel {
    flex: 0 0 460px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .hud-exercise-name {
    font-size: var(--text-2xl);
  }

  .hud-cue-text {
    font-size: var(--text-xl);
  }
}

/* ============================================
   25. DARK MODE PREFERS (System-level)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Already dark theme - ensure consistency */
  body {
    background: var(--bg-primary);
    color: var(--text-primary);
  }
}

/* ============================================
   26. HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  :root {
    --border-subtle: #333333;
    --border-default: #555555;
    --border-strong: #777777;
    --text-secondary: #bbbbbb;
    --text-tertiary: #888888;
  }

  .btn {
    border-width: 2px;
  }

  .hud-cue-bar {
    border-width: 2px;
  }

  .stat-card,
  .mode-card,
  .card,
  .card-raised {
    border-width: 2px;
  }
}

/* ============================================
   27. REDUCED MOTION (Mobile)
   ============================================ */

@media (prefers-reduced-motion: reduce) and (max-width: 1023px) {
  .btn:active,
  .btn-icon:active,
  .mode-card:active,
  .voice-option:active,
  .list-item:active {
    transform: none;
  }

  .hud-cue-bar.has-cue {
    animation: none;
  }

  .camera-scanline::after {
    display: none;
  }

  .bottom-sheet,
  .modal {
    animation: fadeIn 150ms ease forwards;
  }

  .stat-value {
    transition: none;
  }
}

/* ============================================
   28. KEYBOARD OPEN HANDLING (Mobile)
   ============================================ */

@media (max-width: 1023px) {
  /* When virtual keyboard is open, shrink camera */
  .app-shell.keyboard-open .camera-panel {
    flex: 0 0 25vh;
  }

  .app-shell.keyboard-open .side-panel {
    flex: 1;
  }
}

/* ============================================
   29. DISABLED CAMERA STATE (Mobile)
   ============================================ */

@media (max-width: 1023px) {
  .camera-panel.offline {
    flex: 0 0 30vh;
    background: var(--bg-secondary);
  }

  .camera-panel.offline .camera-placeholder {
    padding: var(--space-4);
  }

  .camera-panel.offline .camera-placeholder-icon {
    width: 48px;
    height: 48px;
    font-size: var(--text-xl);
  }

  /* When camera is off, controls take more space */
  .app-shell.camera-off .camera-panel {
    display: none;
  }

  .app-shell.camera-off .side-panel {
    flex: 1;
    border-top: none;
  }
}

/* ============================================
   30. SESSION SUMMARY (Mobile Overlay)
   ============================================ */

@media (max-width: 1023px) {
  .session-summary {
    padding: var(--space-4);
  }

  .session-summary-header {
    text-align: center;
    margin-bottom: var(--space-6);
  }

  .session-summary-score {
    font-family: var(--font-mono);
    font-size: var(--text-5xl);
    font-weight: var(--font-black);
    color: var(--accent);
    line-height: var(--leading-none);
  }

  .session-summary-score-label {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-top: var(--space-2);
  }

  .session-summary-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-6);
  }

  .session-summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
  }

  .session-summary-stat-value {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
  }

  .session-summary-stat-label {
    font-size: var(--text-3xs);
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
  }
}
