/* ============================================================================
   Studio Declipper — Compact Dark-Mode Mastering Console UI
   Pure CSS3, Zero Frameworks, High-Contrast Studio Precision
   ============================================================================ */

:root {
  --bg-root: #0a0d12;
  --bg-panel: #11161f;
  --bg-module: #141a24;
  --bg-well: #0c1017;
  --bg-elevated: #1b2331;
  --bg-hover: #222c3d;

  --border-subtle: #1f2937;
  --border-strong: #2d3a4f;

  --text-primary: #e6edf7;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #2dd4bf;
  --accent-cyan-dim: rgba(45, 212, 191, 0.16);
  --accent-blue: #38bdf8;
  --accent-amber: #f59e0b;
  --accent-amber-dim: rgba(245, 158, 11, 0.16);
  --accent-red: #f43f5e;
  --accent-red-dim: rgba(244, 63, 94, 0.18);
  --accent-green: #10b981;
  --accent-purple: #a78bfa;

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.accent-cyan { color: var(--accent-cyan) !important; }
.accent-amber { color: var(--accent-amber) !important; }
.accent-green { color: var(--accent-green) !important; }
.accent-red { color: var(--accent-red) !important; }

/* ==================== APP SHELL ==================== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  min-width: 960px;
}

/* ==================== TOP BAR ==================== */
.topbar {
  height: 48px;
  background: linear-gradient(180deg, #161c27 0%, #10151e 100%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}

.brand-tag {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
}

.file-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.file-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  flex: 1;
  min-width: 0;
  height: 28px;
}

.file-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-format {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent-blue);
  white-space: nowrap;
  margin-left: auto;
}

.monitor-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ==================== BUTTONS & CONTROLS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #3f4f6b;
}

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

.btn-sm { padding: 4px 9px; height: 28px; font-size: 11px; }
.btn-xs { padding: 2px 7px; height: 22px; font-size: 10.5px; }

.btn-primary {
  background: linear-gradient(180deg, #16a394 0%, #0f766e 100%);
  border-color: #2dd4bf;
  color: #ecfeff;
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #1bb8a7 0%, #118a80 100%);
  box-shadow: 0 0 16px rgba(45, 212, 191, 0.35);
}

.btn-primary.needs-render {
  animation: pulse-cyan 1.8s infinite;
}

@keyframes pulse-cyan {
  0%, 100% { box-shadow: 0 0 8px rgba(45, 212, 191, 0.28); }
  50% { box-shadow: 0 0 18px rgba(45, 212, 191, 0.65); }
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

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

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

.btn-export {
  background: linear-gradient(180deg, #1e3a5f 0%, #162b47 100%);
  border-color: #38bdf8;
  color: #e0f2fe;
  height: 28px;
  padding: 0 14px;
}

.btn-export:hover:not(:disabled) {
  background: linear-gradient(180deg, #254a78 0%, #1b365a 100%);
}

/* Segmented Buttons & A/B */
.seg-group, .ab-group {
  display: inline-flex;
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.seg-group.full-width {
  display: flex;
  width: 100%;
}

.seg-group.full-width .btn-seg {
  flex: 1;
}

.btn-seg {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s;
}

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

.btn-seg.active {
  background: var(--bg-elevated);
  color: var(--accent-cyan);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.35);
}

.btn-icon-sm {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 2px 6px;
  cursor: pointer;
  font-size: 12px;
  border-radius: 3px;
}
.btn-icon-sm:hover { background: var(--bg-elevated); color: var(--text-primary); }

/* Bypass & Delta Toggle Buttons */
.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-well);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.12s;
}

.btn-toggle .led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #334155;
}

.btn-bypass.active {
  border-color: var(--accent-amber);
  background: var(--accent-amber-dim);
  color: #fde68a;
}
.btn-bypass.active .led {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

.btn-delta.active {
  border-color: var(--accent-purple);
  background: rgba(167, 139, 250, 0.18);
  color: #ede9fe;
}
.btn-delta.active .led {
  background: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple);
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.engine-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.engine-badge.rt { border-color: rgba(245, 158, 11, 0.45); color: #fcd34d; }
.engine-badge.rt .dot { background: var(--accent-amber); box-shadow: 0 0 6px var(--accent-amber); }

.engine-badge.offline { border-color: rgba(45, 212, 191, 0.5); color: var(--accent-cyan); }
.engine-badge.offline .dot { background: var(--accent-cyan); box-shadow: 0 0 6px var(--accent-cyan); }

.select-sm {
  height: 28px;
  background: var(--bg-well);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
}

.select-sm:focus { outline: 1px solid var(--accent-cyan); }

/* ==================== MAIN WORKSPACE ==================== */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.left-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* ==================== WAVEFORM TOOLBAR ==================== */
.waveform-toolbar {
  height: 36px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 10px;
  flex-shrink: 0;
}

.transport-controls, .view-controls, .zoom-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-transport {
  width: 28px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.btn-transport:hover { background: var(--bg-hover); }
.btn-play.playing {
  background: var(--accent-cyan-dim);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
.btn-loop.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.timecode-lcd {
  background: #070a0f;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-cyan);
  letter-spacing: 0.03em;
  margin-left: 4px;
}

.time-sep { color: var(--text-muted); margin: 0 3px; }
#time-total { color: var(--text-secondary); }

.toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  margin: 0 2px;
}

.zoom-readout {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
  min-width: 42px;
  text-align: center;
}

/* ==================== WAVEFORM VIEWPORT ==================== */
.waveform-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  background: var(--bg-well);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.minimap-wrap {
  height: 36px;
  background: #080b10;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.minimap-wrap canvas,
.main-wave-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.main-wave-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  cursor: crosshair;
}

.wave-legend {
  position: absolute;
  top: 6px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 14, 21, 0.82);
  border: 1px solid rgba(45, 58, 79, 0.65);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 10px;
  color: var(--text-secondary);
  pointer-events: none;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.swatch {
  width: 10px;
  height: 3px;
  border-radius: 1px;
  display: inline-block;
}
.swatch-orig { background: #64748b; }
.swatch-recon { background: #2dd4bf; }
.swatch-clip { background: #f43f5e; height: 8px; width: 6px; opacity: 0.75; }
.swatch-thr { background: repeating-linear-gradient(90deg, #f59e0b 0 3px, transparent 3px 5px); }

.selection-badge {
  color: #7dd3fc;
  font-family: var(--font-mono);
  font-size: 10px;
  border-left: 1px solid var(--border-strong);
  padding-left: 8px;
}

/* Empty State Overlay */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(17, 24, 36, 0.85) 0%, rgba(10, 13, 18, 0.96) 100%);
  z-index: 5;
}

.empty-card {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(17, 22, 31, 0.9);
  padding: 22px 28px;
  text-align: center;
  max-width: 540px;
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.empty-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* ==================== DIAGNOSTICS / STATS STRIP ==================== */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #0d121a;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.stat-cell {
  padding: 6px 10px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.stat-cell:last-child { border-right: none; }

.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-sub {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-bar-track {
  flex: 1;
  height: 5px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-amber), var(--accent-green), var(--accent-cyan));
  transition: width 0.25s ease;
}

/* ==================== DSP CONTROL RACK ==================== */
.control-rack {
  display: grid;
  grid-template-columns: 1.12fr 1fr 1.05fr;
  gap: 1px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.rack-module {
  background: var(--bg-module);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 5px;
}

.module-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--accent-blue);
}

.module-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.param-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.param-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}

.param-head.compact { font-size: 10px; }

.param-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.param-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 52px;
  text-align: right;
}

.param-hint {
  font-size: 10px;
  color: var(--text-muted);
}

.pill-mini {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-well);
  border: 1px solid var(--border-strong);
  color: var(--accent-cyan);
}

/* Asymmetric Split Controls */
.asym-split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 5px 8px;
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.asym-split-row.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.asym-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Custom Studio Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #0a0e14;
  border: 1px solid var(--border-strong);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 2px solid #0b121c;
  box-shadow: 0 0 6px rgba(45, 212, 191, 0.55);
  cursor: pointer;
  transition: transform 0.08s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Mini Switch Checkbox */
.mini-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.mini-switch.compact { font-size: 10px; }

.mini-switch input[type="checkbox"] {
  accent-color: var(--accent-cyan);
  cursor: pointer;
  width: 12px;
  height: 12px;
}

/* Render Box & Progress */
.render-action-box {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.render-buttons {
  display: flex;
  gap: 6px;
}

.btn-render {
  flex: 1;
  height: 30px;
  font-size: 11.5px;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.progress-track {
  height: 4px;
  background: #1e293b;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #2dd4bf);
  transition: width 0.08s linear;
}

.progress-text {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Export Box */
.export-box {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-well);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.export-options {
  display: flex;
  align-items: center;
  gap: 6px;
}

.export-options .select-sm {
  flex: 1;
  height: 24px;
  font-size: 10.5px;
}

/* ==================== RIGHT METER BAY ==================== */
.meter-bay {
  width: 146px;
  background: #0d121a;
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 6px;
  flex-shrink: 0;
}

.meter-bay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.btn-reset-peaks {
  border: 1px solid var(--border-strong);
  background: var(--bg-well);
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
}
.btn-reset-peaks:hover { color: var(--text-primary); border-color: var(--accent-cyan); }

.meter-canvas-wrap {
  flex: 1;
  min-height: 180px;
  background: #070a0f;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
}

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

.meter-readouts {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meter-readout-block {
  background: #070a0f;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
}

.mr-title {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.mr-row {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-secondary);
}

/* ==================== FOOTER STATUS BAR ==================== */
.statusbar {
  height: 24px;
  background: #080b10;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.shortcuts-hint {
  display: flex;
  align-items: center;
  gap: 10px;
}

kbd {
  display: inline-block;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-secondary);
  background: #141a24;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

/* ==================== DRAG & DROP OVERLAY ==================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 12, 19, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay-box {
  border: 2px dashed var(--accent-cyan);
  border-radius: 14px;
  background: rgba(15, 23, 36, 0.95);
  padding: 40px 56px;
  text-align: center;
  box-shadow: 0 0 40px rgba(45, 212, 191, 0.25);
}

.drop-icon {
  font-size: 36px;
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.drop-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.drop-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Responsive compact fallback on narrower screens */
@media (max-width: 1120px) {
  .control-rack {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .shortcuts-hint span:nth-child(n+6) { display: none; }
}
