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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  padding: 20px;
}

h1 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 20px;
  color: #a8dadc;
  letter-spacing: 1px;
}

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: 250px 1fr 270px;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

/* ---- Panel ---- */
.panel {
  background: #16213e;
  border-radius: 12px;
  padding: 18px;
  border: 1px solid #0f3460;
}

.panel h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #a8dadc;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #0f3460;
}

/* ---- Fields ---- */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: #9aa0b0;
  margin-bottom: 5px;
}

.field input[type="file"] {
  width: 100%;
  padding: 8px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.8rem;
  cursor: pointer;
}

.field select,
.field input[type="number"] {
  width: 100%;
  padding: 7px 10px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
}

.field input[type="range"] {
  width: 100%;
  padding: 4px 0;
  cursor: pointer;
  accent-color: #457b9d;
}

/* ---- Color picker row ---- */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-row input[type="color"] {
  width: 38px;
  height: 34px;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}

.color-row .hex-input {
  flex: 1;
  padding: 6px 10px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
  font-family: 'Consolas', 'Courier New', monospace;
  letter-spacing: 1px;
}

.color-row .hex-input:focus {
  outline: none;
  border-color: #457b9d;
}

/* ---- Toggle switch ---- */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.toggle-row > label {
  font-size: 0.85rem;
  color: #c0c8d8;
  margin-bottom: 0;
  cursor: pointer;
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #0f3460;
  border-radius: 22px;
  transition: background 0.3s;
}

.slider::before {
  position: absolute;
  content: '';
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #9aa0b0;
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
}

input:checked + .slider {
  background: #457b9d;
}

input:checked + .slider::before {
  transform: translateX(18px);
  background: #a8dadc;
}

/* ---- Range value label ---- */
.range-value {
  font-size: 0.75rem;
  color: #a8dadc;
  font-family: 'Consolas', monospace;
}

/* ---- Buttons ---- */
.btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-bottom: 8px;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background: #457b9d;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #5a9cbf;
}

.btn-stop {
  background: #e63946;
  color: #fff;
}

.btn-stop:hover:not(:disabled) {
  background: #ff5f6d;
}

.btn-download {
  background: #2a9d8f;
  color: #fff;
}

.btn-download:hover:not(:disabled) {
  background: #35c4b4;
}

.btn-reset {
  width: 100%;
  padding: 7px;
  border: 1px solid #1a4a8a;
  border-radius: 8px;
  background: transparent;
  color: #9aa0b0;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: 0;
}

.btn-reset:hover {
  color: #a8dadc;
  border-color: #457b9d;
}

.btn-play {
  background: #2a9d8f;
  color: #fff;
}

.btn-play:hover:not(:disabled) {
  background: #35c4b4;
}

.btn-export {
  background: #457b9d;
  color: #fff;
}

.btn-export:hover:not(:disabled) {
  background: #5a9cbf;
}

.btn-add-el {
  width: 100%;
  padding: 8px;
  border: 1px dashed #457b9d;
  border-radius: 8px;
  background: transparent;
  color: #a8dadc;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  margin-bottom: 0;
}

.btn-add-el:hover {
  background: rgba(69, 123, 157, 0.15);
}

/* Play + Stop side by side */
.action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-btns .btn {
  margin-bottom: 0;
}

/* ---- Element properties panel ---- */
.el-props-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #a8dadc;
  padding-bottom: 8px;
  border-bottom: 1px solid #0f3460;
}

.btn-icon-del {
  background: none;
  border: none;
  color: #e63946;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-icon-del:hover {
  background: rgba(230, 57, 70, 0.15);
}

.text-input {
  width: 100%;
  padding: 7px 10px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
}

.text-input:focus {
  outline: none;
  border-color: #457b9d;
}

/* ---- Export format tabs ---- */
.export-format-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.fmt-btn {
  padding: 8px;
  border-radius: 8px;
  border: 2px solid #1a4a8a;
  background: #0f3460;
  color: #9aa0b0;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  user-select: none;
}

.fmt-btn.active {
  border-color: #457b9d;
  background: #1a4a8a;
  color: #a8dadc;
}

/* ---- Hint text ---- */
.hint {
  font-size: 0.74rem;
  color: #6a7080;
  margin-top: 4px;
  line-height: 1.4;
}

/* ---- Section separator ---- */
.section-sep {
  border: none;
  border-top: 1px solid #0f3460;
  margin: 14px 0;
}

/* ---- Dual-handle frequency slider ---- */
.freq-slider {
  user-select: none;
}

.freq-slider-track {
  position: relative;
  height: 6px;
  background: #0f3460;
  border-radius: 3px;
  margin: 18px 8px 8px;
  cursor: pointer;
}

.freq-slider-fill {
  position: absolute;
  height: 100%;
  background: #457b9d;
  border-radius: 3px;
  pointer-events: none;
}

.freq-slider-handle {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  background: #a8dadc;
  border: 2px solid #457b9d;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  transition: background 0.15s, box-shadow 0.15s;
  z-index: 1;
}

.freq-slider-handle:hover {
  background: #fff;
  box-shadow: 0 0 0 4px rgba(69, 123, 157, 0.3);
}

.freq-slider-handle.dragging {
  background: #fff;
  cursor: grabbing;
  box-shadow: 0 0 0 5px rgba(69, 123, 157, 0.45);
  z-index: 2;
}

.freq-slider-handle:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(69, 123, 157, 0.4);
}

.freq-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #a8dadc;
  font-family: 'Consolas', monospace;
  padding: 0 8px;
}

/* ---- Preview panel ---- */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#canvas-wrap {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
}

#waveCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- Status bar ---- */
.status-bar {
  background: #0f3460;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #a8dadc;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa0b0;
  flex-shrink: 0;
}

.dot.green {
  background: #2a9d8f;
  animation: pulse 1.2s infinite;
}

.dot.red {
  background: #e63946;
  animation: pulse 0.5s infinite;
}

.dot.orange {
  background: #e9c46a;
}

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

/* ---- FFmpeg status & progress ---- */
#ffmpegStatus {
  font-size: 0.74rem;
  color: #e9c46a;
  margin-top: 6px;
  min-height: 16px;
}

.progress-wrap {
  display: none;
  margin-top: 8px;
}

.progress-wrap.visible {
  display: block;
}

.progress-bar-bg {
  background: #0f3460;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #457b9d;
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}

/* ---- Presets ---- */
.preset-save-row,
.preset-load-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.preset-select {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: #0f3460;
  border: 1px solid #1a4a8a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.85rem;
}

.btn-preset-action {
  padding: 6px 12px;
  background: #457b9d;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-preset-action:hover { background: #5a9cbf; }

/* ---- Export panel (below canvas) ---- */
.export-panel {
  padding: 14px 18px;
}

.export-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  gap: 8px 18px;
  align-items: end;
  margin-bottom: 12px;
}

.export-controls .field {
  margin-bottom: 0;
}

.export-audio-field {
  padding-bottom: 4px;
}

.export-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
}

.export-btns .btn {
  flex: 1;
  width: auto;
  margin-bottom: 0;
}

/* ---- Visualization type thumbnail grid ---- */
.viz-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.viz-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 5px;
  border: 2px solid #1a2a3a;
  border-radius: 7px;
  cursor: pointer;
  background: #0f1f30;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.viz-opt input[type="radio"] {
  display: none;
}

.viz-opt:has(input:checked) {
  border-color: #00d4ff;
  background: #0b2233;
}

.viz-thumb {
  width: 100%;
  aspect-ratio: 5 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viz-thumb svg {
  width: 100%;
  height: 100%;
  fill: #6a7a8a;
  stroke: #6a7a8a;
  overflow: visible;
}

.viz-opt:has(input:checked) .viz-thumb svg {
  fill: #00d4ff;
  stroke: #00d4ff;
}

.viz-label {
  font-size: 0.68rem;
  color: #6a7a8a;
  text-align: center;
  line-height: 1;
}

.viz-opt:has(input:checked) .viz-label {
  color: #00d4ff;
}

/* ---- Inline link button ---- */
.btn-link {
  background: none;
  border: none;
  color: #457b9d;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: #a8dadc;
}
