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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2f3d;
  --text: #e8eaef;
  --muted: #8b919e;
  --accent: #5b8def;
  --start: #34d399;
  --end: #f87171;
  --region: rgba(91, 141, 239, 0.25);
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.drop-zone,
.merge-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.drop-zone:hover,
.drop-zone.dragover,
.merge-drop:hover,
.merge-drop.dragover {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.06);
}

.editor {
  margin-top: 1.5rem;
}

.editor.hidden {
  display: none;
}

.file-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.waveform-wrap {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

#waveform {
  min-height: 100px;
}

.marker-labels {
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  pointer-events: none;
  height: 0;
}

.marker-label {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  transform: translateX(-50%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}

.marker-label.visible {
  opacity: 1;
}

.marker-label.start {
  background: var(--start);
  color: #052e1a;
}

.marker-label.end {
  background: var(--end);
  color: #450a0a;
}

.time-display {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  margin: 0.75rem 0;
}

.time-display .sep {
  color: var(--muted);
  margin: 0 0.25rem;
}

.controls,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

button {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.1);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

button.primary:hover:not(:disabled) {
  background: #4a7de0;
}

.range-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.range-info strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.range-length {
  margin-left: 0.25rem;
}

.range-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.preview-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.preview-mode label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  color: var(--text);
}

.wave-legend {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.8rem;
}

.wave-legend.hidden { display: none; }

.legend-kept { color: var(--start); }
.legend-removed { color: var(--end); }

.waveform-wrap.result-preview {
  box-shadow: 0 0 0 2px var(--start);
}

.merge-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.merge-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.merge-list {
  list-style: none;
  margin: 0.75rem 0;
}

.merge-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  background: var(--surface);
  border-radius: 6px;
  margin-bottom: 0.35rem;
}

.merge-list .remove {
  background: none;
  border: none;
  color: var(--end);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

#mergeBtn {
  width: 100%;
}

.status-panel {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
  background: var(--muted);
}

.status-panel.idle .status-dot { background: var(--muted); }
.status-panel.loading .status-dot,
.status-panel.working .status-dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
.status-panel.success .status-dot { background: var(--start); }
.status-panel.error .status-dot { background: var(--end); }

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

.status-body {
  flex: 1;
  min-width: 0;
}

.status-message {
  font-size: 0.85rem;
  line-height: 1.45;
  word-break: break-word;
}

.status-panel.success .status-message { color: var(--start); }
.status-panel.error .status-message { color: var(--end); }

.status-progress {
  margin-top: 0.5rem;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.status-progress.hidden {
  display: none;
}

.status-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
}

button.processing {
  opacity: 0.6;
  cursor: wait;
}

.section-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.output-section,
.ftp-section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.output-section h2,
.ftp-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.output-list {
  list-style: none;
  margin: 0.75rem 0;
}

.output-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  background: var(--surface);
  border-radius: 6px;
  margin-bottom: 0.35rem;
}

.output-list li.empty {
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.output-list li label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.output-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-list .size {
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.output-list .remove {
  background: none;
  border: none;
  color: var(--end);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

.output-actions,
.ftp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

#exportOutputBtn {
  margin-left: auto;
}

.ftp-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.ftp-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.ftp-form label.checkbox-label {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  color: var(--text);
  font-size: 0.85rem;
}

.section-note code {
  font-size: 0.8em;
  color: var(--accent);
}

.ftp-form input[type="text"],
.ftp-form input[type="number"],
.ftp-form input[type="password"] {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

#ftpUploadBtn {
  flex: 1;
  min-width: 200px;
}

@media (max-width: 520px) {
  .ftp-form { grid-template-columns: 1fr; }
}

/* WaveSurfer region styling */
#waveform [data-id] {
  border-left: 3px solid var(--start) !important;
  border-right: 3px solid var(--end) !important;
  box-sizing: border-box;
}
