/* design tokens */
:root {
  --bg:           #0d0d0d;
  --surface:      #161616;
  --surface-2:    #1f1f1f;
  --border:       #2a2a2a;
  --border-focus: #444;
  --text:         #e2e2e2;
  --text-muted:   #666;
  --accent:       #7dd3fc;
  --accent-dim:   #38bdf822;
  --accent-hover: #38bdf8;
  --danger:       #f87171;
  --success:      #86efac;
  --radius:       6px;
  --radius-lg:    10px;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  --font-sans:    system-ui, -apple-system, sans-serif;
  --transition:   0.15s ease;
}

/* ── reset ────────────────────────────────────────────────────────────────── */

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

/* ── base ─────────────────────────────────────────────────────────────────── */

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── layout ───────────────────────────────────────────────────────────────── */

.container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ── header ───────────────────────────────────────────────────────────────── */

header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

h1 {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.subtitle a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── section card ─────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

/* ── drop zone ────────────────────────────────────────────────────────────── */

#drop-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

#drop-zone.drag-over { border-style: solid; }

#drop-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.875rem;
}

#drop-formats {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  margin-top: 0.4rem;
  opacity: 0.6;
}

/* ── file list ────────────────────────────────────────────────────────────── */

#file-list {
  list-style: none;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.file-meta.loading { opacity: 0.4; }

.remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
  line-height: 1;
}

.remove-btn:hover { color: var(--danger); background: #f8717120; }

/* ── mode selector ────────────────────────────────────────────────────────── */

.mode-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.mode-btn {
  flex: 1;
  padding: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── params grid ──────────────────────────────────────────────────────────── */

.params-grid {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.param-row {
  display: grid;
  grid-template-columns: 160px 1fr 72px;
  align-items: center;
  gap: 0.75rem;
}

.param-label {
  font-size: 0.82rem;
  color: var(--text);
}

.param-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  text-align: right;
}

/* range inputs */
input[type="range"] {
  width: 100%;
  height: 4px;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: background var(--transition);
}

input[type="range"]:hover::-webkit-slider-thumb { background: var(--accent-hover); }

/* ── contrast subsection ──────────────────────────────────────────────────── */

.contrast-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  margin-top: 0.5rem;
}

.contrast-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 9px;
  transition: background var(--transition);
  cursor: pointer;
}

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

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  transition: transform var(--transition);
}

.toggle input:checked + .toggle-track::after { transform: translateX(14px); }

#contrast-params {
  transition: opacity var(--transition);
}

#contrast-params.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ── action row ───────────────────────────────────────────────────────────── */

.action-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#process-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 0.65rem 2.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}

#process-btn:hover:not(:disabled) { background: var(--accent-hover); }

#process-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#process-btn.processing { opacity: 0.6; }

#status-bar {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-height: 1.2em;
}

#status-bar.error { color: var(--danger); }
#status-bar.success { color: var(--success); }

/* ── output section ───────────────────────────────────────────────────────── */

#output-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#output-section[hidden] { display: none; }

#waveform-canvas {
  width: 100%;
  height: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: block;
}

audio {
  width: 100%;
  height: 36px;
  border-radius: var(--radius);
  accent-color: var(--accent);
}

/* custom audio element tinting (chromium) */
audio::-webkit-media-controls-panel { background: var(--surface-2); }

.output-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#download-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

#download-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .param-row { grid-template-columns: 130px 1fr 60px; }
  #process-btn { padding: 0.65rem 1.5rem; }
}
