/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #08080a;
  --bg-panel: #141418;
  --surface: #1e1e24;
  --surface-light: #2a2a32;
  --border: #2a2a30;
  --border-light: #383840;

  --text: #d4d0c8;
  --text-dim: #8a8a94;
  --text-muted: #555560;
  --text-engraved: #6a6a72;

  --amber: #d4a23a;
  --amber-glow: rgba(212, 162, 58, 0.4);
  --amber-dim: #8a6a20;
  --blue: #4878b8;
  --blue-glow: rgba(72, 120, 184, 0.4);
  --green: #4a9a5e;
  --red: #c44;

  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 6px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem 2rem;
}

/* ===== Header / Branding ===== */
.app-header {
  text-align: center;
  padding: 2rem 0 1.2rem;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #f0d070 0%, #c8962a 60%, #9a6e18 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(212, 162, 58, 0.2));
  line-height: 1.1;
}

.brand-sub {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ===== Drop Zone ===== */
.drop-zone {
  width: 100%;
  max-width: 580px;
  margin: 0.5rem auto 1rem;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-panel);
  transition: all var(--transition);
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--amber);
  background: rgba(212, 162, 58, 0.03);
  box-shadow: 0 0 40px rgba(212, 162, 58, 0.08);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 2rem;
  gap: 0.5rem;
}

.drop-icon {
  color: var(--text-muted);
  transition: color var(--transition);
}

.drop-zone:hover .drop-icon { color: var(--amber); }

.drop-label {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}

.drop-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
}

.btn-browse {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  font-family: var(--font-body);
  text-transform: none;
  font-size: 0.78rem;
}

.btn-browse:hover { color: var(--text); border-color: var(--text-muted); }

.btn-process {
  background: linear-gradient(180deg, #d4a23a 0%, #b8862a 100%);
  color: #111;
  font-weight: 600;
  padding: 0.6rem 1.6rem;
  box-shadow: 0 2px 12px rgba(212, 162, 58, 0.2);
}

.btn-process:hover { filter: brightness(1.1); box-shadow: 0 2px 20px rgba(212, 162, 58, 0.35); }
.btn-process:disabled { opacity: 0.4; cursor: not-allowed; filter: none; box-shadow: none; }

.btn-transport {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-transport:hover { background: var(--surface-light); color: var(--text); }
.btn-transport.active { color: var(--amber); border-color: var(--amber-dim); background: rgba(212, 162, 58, 0.06); }
.btn-transport:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-download {
  background: var(--green);
  color: #fff;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
}

.btn-download:hover { filter: brightness(1.15); }
.btn-download:disabled { opacity: 0.3; cursor: not-allowed; filter: none; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  transition: color var(--transition);
  line-height: 1;
}

.btn-icon:hover { color: var(--red); }

/* ===== File Info ===== */
.file-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  margin: 0 auto 0.8rem;
  max-width: 960px;
  width: 100%;
}

.file-info-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.file-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(74, 154, 94, 0.5);
  flex-shrink: 0;
}

.file-name {
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-duration {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* ======================================================
   RACK UNIT — Two vintage hardware panels side by side
   ====================================================== */
.rack-unit {
  display: flex;
  gap: 3px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 10px 50px rgba(0,0,0,0.7),
    0 2px 8px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.02);
}

/* ===== Hardware Panel (shared) ===== */
.hw-panel {
  position: relative;
  padding: 0.6rem 1.2rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  /* Brushed metal texture */
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 1px,
      rgba(255,255,255,0.003) 1px,
      rgba(255,255,255,0.003) 2px
    ),
    linear-gradient(180deg, #222230 0%, #1a1a24 30%, #151520 70%, #121218 100%);
  border: 1px solid rgba(255,255,255,0.04);
}

.eq-panel {
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 1px,
      rgba(255,255,255,0.004) 1px,
      rgba(255,255,255,0.004) 2px
    ),
    linear-gradient(180deg, #1e2038 0%, #181828 30%, #141420 70%, #10101a 100%);
}

.comp-panel {
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 1px,
      rgba(255,255,255,0.003) 1px,
      rgba(255,255,255,0.003) 2px
    ),
    linear-gradient(180deg, #242430 0%, #1c1c26 30%, #161620 70%, #121218 100%);
}

.meter-panel {
  background: var(--bg-meter);
  flex: 0.8;
  min-width: 0;
}

/* ===== Panel Screws ===== */
.panel-screws {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 0.2rem;
  margin-bottom: 0.2rem;
}

.panel-screws.bottom {
  margin-bottom: 0;
  margin-top: auto;
  padding-top: 0.4rem;
}

.screw {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4a4a52, #2a2a2e 55%, #1a1a20);
  border: 1px solid rgba(0,0,0,0.6);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,0.06),
    0 1px 2px rgba(0,0,0,0.4);
  position: relative;
}

.screw::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(30deg);
  width: 7px;
  height: 1.2px;
  background: rgba(0,0,0,0.5);
  border-radius: 1px;
}

.screw::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(120deg);
  width: 7px;
  height: 1.2px;
  background: rgba(0,0,0,0.5);
  border-radius: 1px;
}

/* ===== Panel Title Bar ===== */
.panel-title-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.3rem 0 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  margin-bottom: 0.6rem;
  position: relative;
}

.panel-model {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  opacity: 0.5;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--text-engraved);
  text-transform: uppercase;
}

/* Indicator lights */
.indicator-light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.4);
}

.indicator-light.amber {
  background: radial-gradient(circle at 40% 40%, #f0c050, #c88a20);
  box-shadow: 0 0 8px var(--amber-glow), inset 0 -1px 1px rgba(0,0,0,0.3);
}

.indicator-light.blue {
  background: radial-gradient(circle at 40% 40%, #6090d0, #3060a0);
  box-shadow: 0 0 8px var(--blue-glow), inset 0 -1px 1px rgba(0,0,0,0.3);
}

/* ===== Hardware Controls ===== */
.hw-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.2rem;
  padding: 0.6rem 0;
  flex: 1;
  align-content: center;
}

.hw-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-height: 110px;
}

/* Labels above and below knobs */
.hw-label-top {
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-engraved);
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 0.15rem;
}

.hw-label-bottom {
  font-family: var(--font-display);
  font-size: 0.5rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center;
  margin-top: 0.5rem;
  opacity: 0.6;
}

.hw-sublabel {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.6rem;
}

.hw-freq-badge {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* Divider between control groups */
.panel-divider {
  width: 1px;
  height: 80px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.06), transparent);
  align-self: center;
}

/* ===== Panel Footer ===== */
.panel-footer {
  width: 100%;
  text-align: center;
  padding: 0.4rem 0 0.2rem;
  border-top: 1px solid rgba(255,255,255,0.03);
  margin-top: 0.4rem;
}

.panel-serial {
  font-family: var(--font-display);
  font-size: 0.48rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  opacity: 0.35;
  text-transform: uppercase;
}

/* ===== Knob Housing ===== */
.knob-housing {
  background: radial-gradient(circle, rgba(0,0,0,0.25) 0%, transparent 70%);
  border-radius: 50%;
  padding: 4px;
  margin-bottom: 0.3rem;
  position: relative;
}

.knob-housing.large {
  padding: 8px;
  margin-bottom: 0.4rem;
}

.knob-housing.large .knob {
  width: 88px;
  height: 88px;
}

.knob {
  width: 64px;
  height: 64px;
  position: relative;
  cursor: grab;
  display: block;
  margin-bottom: 0;
}

.knob:active { cursor: grabbing; }
.knob canvas { width: 100%; height: 100%; }

.knob-value {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,0.5);
  font-weight: 500;
  z-index: 10;
}

/* ===== Hardware Select (Freq Picker) ===== */
.hw-select {
  background: rgba(0,0,0,0.35);
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 3px;
  padding: 0.15rem 0.3rem;
  font-size: 0.58rem;
  font-family: var(--font-mono);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  text-align: center;
  margin-top: 0.4rem;
}

.hw-select:hover, .hw-select:focus { border-color: var(--text-muted); }

/* ===== VU Meter ===== */
.vu-meter-housing {
  background: #0c0c0e;
  border: 2px solid #333338;
  border-radius: 6px;
  padding: 6px;
  margin: 0.6rem 0;
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.6),
    0 1px 0 rgba(255,255,255,0.04),
    0 0 20px rgba(212, 162, 58, 0.15);
  width: 100%;
  max-width: 260px;
}

.vu-meter {
  background: linear-gradient(180deg, #e8d8a0 0%, #d4c080 30%, #c8b060 100%);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  box-shadow:
    inset 0 0 30px rgba(212, 162, 58, 0.4),
    0 0 15px rgba(212, 162, 58, 0.2);
}

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

.meter-label-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 0.4rem;
}

.meter-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.meter-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber-glow);
}

/* ===== Waveform Section ===== */
.waveform-section {
  max-width: 960px;
  width: 100%;
  margin: 0.5rem auto;
}

.waveform-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  border-radius: var(--radius);
  overflow: hidden;
}

.waveform-panel {
  background: var(--bg-panel);
  padding: 0.8rem;
  position: relative;
}

.waveform-label {
  position: absolute;
  top: 0.5rem;
  left: 0.8rem;
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 500;
}

.waveform-panel canvas {
  width: 100%;
  height: 100px;
  display: block;
  cursor: pointer;
}

.waveform-panel .playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  opacity: 0.75;
  pointer-events: none;
  left: 0;
  display: none;
  box-shadow: 0 0 6px rgba(255,255,255,0.25);
}

.waveform-time {
  position: absolute;
  top: 0.5rem;
  right: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: var(--text-dim);
}

/* ===== Transport Section ===== */
.transport-section {
  max-width: 960px;
  width: 100%;
  margin: 0.5rem auto;
}

.transport-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
}

.transport-left, .transport-right { flex-shrink: 0; }

.transport-center {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ===== Progress ===== */
.progress-container {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--amber), var(--blue));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
  font-family: var(--font-mono);
  min-width: 90px;
}

/* ===== Footer ===== */
.app-footer {
  margin-top: auto;
  padding: 2rem 0 0.5rem;
  text-align: center;
}

.app-footer p {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .rack-unit { flex-direction: column; }
  .waveform-container { grid-template-columns: 1fr; }
  .transport-bar { flex-direction: column; gap: 0.6rem; }
  .transport-center { order: -1; }
  .panel-divider { width: 60px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent); }
  .knob-housing.large .knob { width: 68px; height: 68px; }
}

@media (max-width: 480px) {
  .brand-title { font-size: 2rem; }
  .knob { width: 54px; height: 54px; }
  .knob-housing.large .knob { width: 62px; height: 62px; }
  .hw-controls { gap: 0.8rem; }
}

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

.rack-unit, .waveform-section, .transport-section, .file-info {
  animation: fadeIn 0.35s ease forwards;
}

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

.btn-process.processing {
  animation: pulse 1.2s ease infinite;
  pointer-events: none;
}
