:root {
  --bg: #111;
  --surface: #1a1a1a;
  --surface2: #222;
  --border: #333;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #e85d04;
  --green: #2d9e5f;
  --yellow: #c9a227;
  --blue: #2d7fd3;
  --red: #c0392b;
  --radius: 6px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-right: 16px;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all 0.15s;
}
nav a:hover { color: var(--text); background: var(--surface2); }
nav a.active { color: var(--text); background: var(--surface2); font-weight: 600; }

main { padding: 24px; max-width: 960px; margin: 0 auto; }

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 20px; font-weight: 700; }

/* Buttons */
.btn {
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn:hover { border-color: #555; background: #2a2a2a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #f47818; }
.btn.danger { color: var(--red); border-color: transparent; background: transparent; }
.btn.danger:hover { background: rgba(192,57,43,0.15); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge.green { background: rgba(45,158,95,0.2); color: #4ec98a; }
.badge.yellow { background: rgba(201,162,39,0.2); color: #e8bb3a; }
.badge.grey { background: rgba(100,100,100,0.2); color: var(--muted); }
.badge.blue { background: rgba(45,127,211,0.2); color: #5aafff; }

.meta { color: var(--muted); font-size: 12px; }
.dim { opacity: 0.6; }

/* Recordings */
.recordings-list { display: flex; flex-direction: column; gap: 12px; }

.recording-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.rec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
}
.rec-header strong { display: block; margin-bottom: 2px; }
.rec-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Segments */
.segments-container { padding: 0 16px 16px; }

.segment-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.segment-type {
  width: 70px;
  text-align: center;
}

.segment-player audio {
  width: 280px;
  height: 32px;
}

.segment-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.segment-actions { display: flex; gap: 4px; }

/* Type selector */
.type-select {
  appearance: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
}
.type-select.music { border-color: var(--green); color: #4ec98a; }
.type-select.speech { border-color: var(--muted); color: var(--muted); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  min-width: 420px;
  max-width: 520px;
}
.modal-box h2 { margin-bottom: 16px; font-size: 16px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(232,93,4,0.05);
}
.drop-zone small { color: var(--muted); display: block; margin-top: 4px; }

/* Progress bar */
.progress-bar {
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin: 12px 0 8px;
}
#progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
}

/* Upload options */
#upload-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
#upload-options input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  border-radius: var(--radius);
  width: 80px;
}

/* Assign modal */
.assign-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
}
.assign-form select, .assign-form input[type=text] {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
}
.or-divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0;
}
.assign-form input[type=checkbox] { margin-right: 8px; }

/* Stars */
.stars span, .stars-display {
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.1s;
}
.stars span.active, .stars span:hover ~ span, .stars:hover span { color: var(--yellow); }

/* Songs */
.songs-grid { display: flex; flex-direction: column; gap: 10px; }

.song-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.song-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.song-title {
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}
.song-title:hover { color: var(--accent); }

.song-meta { display: flex; gap: 6px; }
.song-actions { display: flex; gap: 4px; }

.versions-list { padding: 0 16px 16px; }

.version-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.version-row.primary { background: rgba(45,158,95,0.04); }
.version-row audio { width: 280px; height: 32px; }

.version-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.version-actions { display: flex; gap: 4px; }

.stars-display { color: var(--yellow); font-size: 13px; letter-spacing: 1px; }
.no-versions { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* Inline form */
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
}
.inline-form input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius);
  flex: 1;
  max-width: 300px;
}

/* Playlist */
.add-to-playlist {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.add-to-playlist select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius);
  flex: 1;
  max-width: 320px;
}

.playlist-list { display: flex; flex-direction: column; gap: 6px; }

.playlist-row {
  display: grid;
  grid-template-columns: 24px 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  transition: background 0.1s;
}
.playlist-row:active { cursor: grabbing; }
.playlist-row.drag-over { border-color: var(--accent); background: rgba(232,93,4,0.05); }

.drag-handle { color: var(--muted); user-select: none; font-size: 16px; }
.pos-num { color: var(--muted); font-size: 12px; text-align: right; }

.pl-info { display: flex; flex-direction: column; gap: 4px; }
.pl-info strong { font-size: 14px; }
.pl-info audio { width: 300px; height: 30px; }

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 0;
  color: var(--muted);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.hidden { display: none !important; }
