/**
 * SoundForge AI - Global Styles
 * Brand: Futuristic Studio (Dark Theme)
 * Version: 2.1.0
 */

/* ===== CSS CUSTOM PROPERTIES (Brand Identity) ===== */
:root {
  /* === BRAND IDENTITY: SoundForge AI === */
  /* Archetype: FUTURISTIC STUDIO */
  
  /* Primary Palette */
  --brand-primary: #00d4ff;
  --brand-secondary: #7b2ff7;
  --brand-accent: #ff6b6b;
  --brand-success: #00ff88;
  --brand-warning: #ffaa00;
  
  /* Background Colors */
  --bg-primary: #0a0a1a;
  --bg-secondary: #111128;
  --bg-tertiary: #1a1a3e;
  --bg-elevated: #222250;
  --bg-hover: #2a2a5e;
  
  /* Text Colors */
  --text-primary: #eaeaea;
  --text-secondary: #a0a0b8;
  --text-muted: #6a6a80;
  --text-inverse: #0a0a1a;
  
  /* Audio-Specific Colors */
  --waveform-bg: #0d1b2a;
  --waveform-primary: #00d4ff;
  --waveform-secondary: #7b2ff7;
  --waveform-fill: rgba(0, 212, 255, 0.25);
  --selection-color: rgba(123, 47, 247, 0.4);
  --playhead-color: #ff6b6b;
  
  /* Level Meters */
  --meter-green: #00ff88;
  --meter-yellow: #ffaa00;
  --meter-red: #ff4444;
  --meter-bg: #1a1a3e;
  
  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  
  /* Spacing Scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 2px 4px 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-glow-primary: 0 0 20px rgba(0, 212, 255, 0.3);
  --shadow-glow-accent: 0 0 20px rgba(255, 107, 107, 0.3);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
  
  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* ===== RESET & BASE STYLES ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Skip Link for Accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--brand-primary);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  z-index: var(--z-toast);
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 var(--radius-md) 0;
}

.skip-link:focus {
  top: 0;
}

/* ===== APP CONTAINER ===== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1920px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--bg-secondary);
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(10px);
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-center {
  flex: 1;
  justify-content: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.app-title .accent {
  color: var(--brand-primary);
}

.project-name {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-name:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: var(--text-inverse);
  font-weight: 600;
  box-shadow: var(--shadow-glow-primary);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-transport {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
  padding: var(--space-3);
  border-radius: var(--radius-full);
}

.btn-transport:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-play {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: var(--text-inverse);
  padding: var(--space-3) var(--space-5);
}

.btn-play:hover:not(:disabled) {
  box-shadow: var(--shadow-glow-primary);
}

.btn-icon {
  background: transparent;
  color: var(--text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

.btn-icon:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-small {
  padding: var(--space-1) var(--space-2);
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn-small:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-op {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  text-align: left;
  transition: all var(--transition-fast);
}

.btn-op:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  transform: translateX(4px);
}

.btn-block {
  width: 100%;
}

.btn-close {
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  padding: var(--space-1);
  line-height: 1;
}

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

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  gap: var(--space-4);
  overflow: hidden;
}

/* ===== TRANSPORT SECTION ===== */
.transport-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.transport-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-4);
  padding-left: var(--space-4);
  border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border-radius: 2px;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--brand-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-glow-primary);
}

.volume-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 36px;
}

.time-display {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-width: 100px;
}

.time-separator {
  color: var(--text-muted);
}

/* Progress Bar */
.progress-container {
  margin-top: var(--space-4);
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
}

.progress-bar {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: var(--brand-primary);
  border-radius: 50%;
  box-shadow: var(--shadow-glow-primary);
  left: 0%;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.progress-track:hover .progress-handle {
  opacity: 1;
}

/* ===== WAVEFORM SECTION ===== */
.waveform-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.waveform-container {
  flex: 1;
  position: relative;
  background: var(--waveform-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 150px;
}

.waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.waveform-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.selection-box {
  position: absolute;
  background: var(--selection-color);
  border: 2px solid var(--brand-secondary);
  pointer-events: auto;
  cursor: move;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  pointer-events: none;
  z-index: 10;
}

.playhead-line {
  width: 100%;
  height: 100%;
  background: var(--playhead-color);
  box-shadow: 0 0 8px var(--playhead-color);
}

.waveform-time-ruler {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.zoom-slider {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border-radius: 2px;
  cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--brand-secondary);
  border-radius: 50%;
  cursor: pointer;
}

/* ===== WORKSPACE LAYOUT ===== */
.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-4);
  flex: 1;
  min-height: 0;
}

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}

/* ===== OPERATIONS PANEL ===== */
.operations-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  overflow-y: auto;
  max-height: calc(100vh - 300px);
}

.panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.operation-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.op-tab {
  padding: var(--space-2) var(--space-3);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.op-tab.active {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(123, 47, 247, 0.2));
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.op-panel {
  animation: fadeIn 0.2s ease;
}

.op-panel[hidden] {
  display: none;
}

.op-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

.param-group {
  margin-bottom: var(--space-4);
}

.param-group > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.param-select,
.param-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.param-select:focus,
.param-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.modify-operations {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.op-icon {
  font-size: 1.25rem;
}

/* Effect Items */
.effect-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.effect-item {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.effect-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
}

.effect-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-primary);
}

.effect-params {
  margin-top: var(--space-3);
  padding-left: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.effect-params label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.effect-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-elevated);
  border-radius: 2px;
  cursor: pointer;
}

.effect-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--brand-secondary);
  border-radius: 50%;
  cursor: pointer;
}

/* Analysis Results */
.analysis-results {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

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

.analysis-visuals {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.analyzer-container,
.meters-container {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.analyzer-container h4,
.meters-container h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.spectrum-canvas {
  width: 100%;
  height: 120px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}

.stereo-meter {
  display: flex;
  gap: var(--space-4);
}

.meter-channel {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.meter-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 16px;
}

.meter-bar {
  flex: 1;
  height: 20px;
  background: var(--meter-bg);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--meter-green), var(--meter-yellow), var(--meter-red));
  transition: width 0.05s linear;
}

.meter-peak {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--text-primary);
}

.meter-db {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 42px;
}

/* ===== VISUALIZATION PANEL ===== */
.viz-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.viz-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.viz-tab {
  padding: var(--space-2) var(--space-3);
  font-size: 0.8rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.viz-tab.active {
  background: var(--bg-elevated);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.viz-content {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.viz-canvas {
  width: 100%;
  height: 200px;
  display: block;
}

/* ===== STATUS BAR ===== */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-secondary);
  border-top: 2px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-left,
.status-center,
.status-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-dot.ready { background: var(--brand-success); }
.status-dot.working { background: var(--brand-warning); }
.status-dot.error { background: var(--brand-accent); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.separator {
  color: var(--bg-elevated);
}

/* ===== MODAL ===== */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 500px;
  width: 90%;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

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

.shortcut-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  align-items: baseline;
}

.shortcut-list dt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--brand-primary);
}

.shortcut-list dd {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  pointer-events: auto;
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

.toast.success { border-left: 3px solid var(--brand-success); }
.toast.error { border-left: 3px solid var(--brand-accent); }
.toast.info { border-left: 3px solid var(--brand-primary); }
.toast.warning { border-left: 3px solid var(--brand-warning); }

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

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 26, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  gap: var(--space-4);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet (641px - 1024px) */
@media (max-width: 1024px) and (min-width: 641px) {
  .workspace {
    grid-template-columns: 260px 1fr;
  }
  
  .volume-slider {
    width: 60px;
  }
  
  .zoom-slider {
    width: 80px;
  }
}

/* Mobile Landscape & Small Tablet (640px - 768px) */
@media (max-width: 768px) and (min-width: 641px) {
  .app-header {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
  
  .header-center {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    margin-top: var(--space-2);
  }
  
  .transport-controls {
    gap: var(--space-2);
  }
  
  .volume-control {
    margin-left: var(--space-2);
    padding-left: var(--space-2);
  }
  
  .time-display {
    margin-left: var(--space-2);
    min-width: auto;
  }
  
  .modify-operations {
    grid-template-columns: 1fr;
  }
  
  .workspace {
    grid-template-columns: 1fr;
  }
  
  .operations-panel {
    max-height: none;
  }
  
  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
  }
  
  .shortcut-list {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
  
  .shortcut-list dt {
    margin-top: var(--space-2);
  }
}

/* Mobile Portrait (<640px) */
@media (max-width: 640px) {
  .app-header {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
  
  .header-center {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    margin-top: var(--space-2);
  }
  
  /* Transport controls - prevent overflow */
  .transport-controls {
    gap: var(--space-1);
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-1);
  }
  
  .btn-transport {
    min-width: 44px;
    min-height: 44px;
  }
  
  .btn-play {
    min-width: 52px;
    min-height: 52px;
  }
  
  /* Volume control - responsive slider */
  .volume-control {
    margin-left: var(--space-1);
    padding-left: var(--space-2);
    flex-shrink: 0;
  }
  
  .volume-slider {
    width: 60px;
    min-width: 50px;
  }
  
  /* Time display - flexible */
  .time-display {
    margin-left: var(--space-1);
    min-width: auto;
    font-size: 0.75rem;
  }
  
  /* Workspace - single column */
  .workspace {
    grid-template-columns: 1fr;
  }
  
  .operations-panel {
    max-height: none;
  }
  
  /* Modals - full width on small screens */
  .modal {
    width: 95%;
    max-height: 85vh;
  }
  
  .modal-header,
  .modal-body {
    padding: var(--space-3) var(--space-4);
  }
  
  /* Toast notifications */
  .toast-container {
    left: var(--space-2);
    right: var(--space-2);
    bottom: var(--space-2);
  }
  
  .toast {
    max-width: 100%;
    font-size: 0.8rem;
  }
  
  /* Shortcuts list - stack vertically */
  .shortcut-list {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
  
  .shortcut-list dt {
    margin-top: var(--space-2);
  }
  
  /* Zoom controls */
  .zoom-slider {
    width: 70px;
    min-width: 60px;
  }
  
  /* Main content adjustments */
  .main-content {
    padding: var(--space-3);
    gap: var(--space-3);
  }
  
  /* Waveform section */
  .waveform-section {
    padding: var(--space-3);
    min-height: 150px;
  }
  
  .waveform-container {
    min-height: 120px;
  }
  
  /* Operation tabs - scrollable on very small screens */
  .operation-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: var(--space-2);
  }
  
  .op-tab {
    flex-shrink: 0;
  }
  
  /* Parameter inputs - touch friendly */
  .param-select,
  .param-input {
    font-size: 16px; /* Prevent iOS zoom on focus */
  }
  
  /* Effect sliders - larger touch targets */
  .effect-slider {
    height: 8px;
    min-height: 44px;
    padding: 18px 0;
  }
  
  .effect-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  
  /* Meter bars */
  .meter-bar {
    height: 16px;
  }
  
  /* Status bar */
  .status-bar {
    font-size: 0.65rem;
    padding: var(--space-1) var(--space-2);
  }
  
  .status-left,
  .status-right {
    gap: var(--space-2);
  }
}

/* Very Small Screens (<380px) */
@media (max-width: 380px) {
  .app-title {
    font-size: 1rem;
  }
  
  .transport-controls {
    gap: 4px;
  }
  
  .btn-transport {
    min-width: 40px;
    min-height: 40px;
    padding: var(--space-1);
  }
  
  .volume-slider {
    width: 50px;
  }
  
  .time-display {
    font-size: 0.7rem;
  }
  
  .zoom-slider {
    width: 60px;
  }
  
  .op-tab {
    padding: var(--space-1) var(--space-2);
    font-size: 0.75rem;
  }
  
  .panel-title {
    font-size: 0.75rem;
  }
}



/* ===== TABLET RANGE (768px - 1024px) - Fix visual break ===== */
@media (min-width: 768px) and (max-width: 1024px) {
  .workspace {
    grid-template-columns: 240px 1fr;
    gap: var(--space-3);
  }
  
  .sidebar-left {
    max-width: 240px;
    min-width: 0;
    overflow-x: hidden;
  }
  
  .main-content {
    padding: var(--space-3);
    min-width: 0;
    overflow-x: hidden;
  }
  
  .operation-panel {
    padding: var(--space-3);
  }
  
  .waveform-container {
    height: 160px;
  }
  
  .transport-bar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .progress-section {
    order: 3;
    width: 100%;
    min-width: unset;
  }
  
  /* Ensure operation panel doesn't overflow */
  .operation-panel-body {
    max-height: calc(100dvh - 260px);
    overflow-y: auto;
  }
  
  /* Grid adjustments */
  .param-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }
  
  .toggles-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .download-buttons {
    grid-template-columns: 1fr 1fr;
  }
  
  .download-buttons .btn-download:last-child {
    grid-column: span 2;
  }
}

/* ===== CRITICAL FIX: 800px - 900px Visual Break Zone ===== */
@media (min-width: 801px) and (max-width: 900px) {
  .workspace {
    grid-template-columns: 220px 1fr !important;
    gap: var(--space-2);
  }
  
  .sidebar-left {
    max-width: 220px !important;
    padding: var(--space-2);
  }
  
  .sidebar-left .panel {
    padding: var(--space-2);
  }
  
  .main-content {
    padding: var(--space-2) !important;
  }
  
  .operation-panel {
    padding: var(--space-2);
  }
  
  .operation-panel-body {
    max-height: calc(100dvh - 240px) !important;
  }
  
  /* Compact waveform */
  .waveform-container {
    height: 140px !important;
  }
  
  .waveform-header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  /* Transport bar - more compact */
  .transport-bar {
    flex-wrap: wrap;
    gap: var(--space-1) !important;
    padding: var(--space-2);
  }
  
  .transport-buttons {
    gap: 4px !important;
  }
  
  .btn-transport {
    width: 36px !important;
    height: 36px !important;
    padding: 6px !important;
  }
  
  .progress-section {
    order: 3;
    width: 100% !important;
    min-width: unset !important;
  }
  
  .volume-control {
    width: 100%;
    justify-content: center;
    margin-top: var(--space-1);
  }
  
  /* Grids go single column if too cramped */
  .param-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--space-2) !important;
  }
  
  .toggles-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--space-2) !important;
  }
  
  .download-buttons {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--space-2) !important;
  }
  
  .download-buttons .btn-download:last-child {
    grid-column: span 2;
  }
  
  /* Presets row wrap */
  .presets-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .preset-btn {
    font-size: 0.75rem;
    padding: 6px 10px;
  }
  
  /* Form elements compact */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 0.85rem;
  }
  
  .form-label {
    font-size: 0.8rem;
  }
  
  /* Prompt chains compact */
  .prompt-chain-container.compact .prompt-input {
    min-height: 32px;
    font-size: 0.8rem;
  }
  
  /* Section headers smaller */
  .collapsible-header {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
  
  /* Nested options compact */
  .nested-options {
    padding: var(--space-2);
  }
  
  .nested-options-title {
    font-size: 0.8rem;
  }
}

/* ===== SMALL DESKTOP (1025px - 1200px) - Bridge gap ===== */
@media (min-width: 1025px) and (max-width: 1200px) {
  .workspace {
    grid-template-columns: 300px 1fr;
    gap: var(--space-4);
  }
  
  .main-content {
    padding: var(--space-4);
  }
  
  .operation-panel-body {
    max-height: calc(100dvh - 300px);
  }
}

/* Ultrawide Screens (>1440px) */
@media (min-width: 1440px) {
  .app-container {
    max-width: 100%;
  }
  
  .workspace {
    grid-template-columns: 360px 1fr;
    gap: var(--space-6);
  }
  
  .main-content {
    padding: var(--space-6);
  }
  
  .waveform-section {
    padding: var(--space-6);
  }
  
  .operations-panel {
    padding: var(--space-6);
  }
  
  .modal {
    max-width: 600px;
  }
}

/* 4K Screens (>2560px) */
@media (min-width: 2560px) {
  html {
    font-size: 18px;
  }
  
  .app-container {
    max-width: 2400px;
  }
  
  .workspace {
    grid-template-columns: 400px 1fr;
    gap: var(--space-8);
  }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .status-dot {
    animation: none;
  }
  
  .loading-spinner {
    animation: none;
    border-top-color: var(--brand-primary);
    border-right-color: var(--brand-primary);
  }
}

/* ===== FOCUS VISIBLE ===== */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}
