:root {
  --bg: #0a0f1e;
  --bg-2: #0f1629;
  --surface: #131d35;
  --surface-2: #1a2544;
  --surface-3: #1f2d52;
  --border: #1e2d50;
  --border-strong: #263660;
  --text: #e8edf8;
  --text-secondary: #8fa3cc;
  --text-muted: #4d6490;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.12);
  --primary-border: rgba(59, 130, 246, 0.3);
  --primary-glow: rgba(59, 130, 246, 0.2);

  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.12);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);

  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.12);

  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 24px rgba(59, 130, 246, 0.15);

  --player-height: 100px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: 14px; }

.hidden { display: none !important; }

/* ─── App Shell ─── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--player-height) + 20px);
}

/* ─── Topbar ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-icon svg { width: 40px; height: 40px; display: block; }

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

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

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 28px rgba(59, 130, 246, 0.35);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.icon-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn-sm:hover { background: var(--surface-2); color: var(--text); }

/* ─── Workspace ─── */
.workspace {
  flex: 1;
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ─── Sidebar ─── */
.sidebar {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-section,
.sidebar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  box-shadow: var(--shadow-sm);
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, color 0.14s;
  font-size: 14px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.nav-item-left span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.count-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.nav-item.active .count-badge {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

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

.playlist-nav-row {
  display: flex;
  align-items: center;
  gap: 3px;
}
.playlist-nav-row .nav-item { flex: 1; min-width: 0; }

.playlist-quick-play {
  opacity: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s;
}
.playlist-nav-row:hover .playlist-quick-play,
.playlist-quick-play:focus { opacity: 1; }
.playlist-quick-play:hover { background: var(--primary); color: #fff; }

.sidebar-empty {
  padding: 12px 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.sidebar-tip {
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(245,158,11,0.04));
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
  font-size: 12.5px;
  color: #fbbf24;
  line-height: 1.5;
}
.sidebar-tip-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: #fcd34d;
}
.sidebar-tip p { margin: 0; opacity: 0.85; }

/* ─── Main Content ─── */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ─── Recorder Card ─── */
.recorder-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.recorder-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.recorder-card.is-recording {
  border-color: rgba(239,68,68,0.3);
  box-shadow: 0 0 30px rgba(239,68,68,0.1);
}
.recorder-card.is-recording::before {
  background: linear-gradient(90deg, var(--danger), #f97316);
}

.recorder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.recorder-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.recorder-title-group h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 0.2s;
}
.recorder-card.is-recording .rec-dot {
  background: var(--danger);
  animation: pulseDot 1s infinite;
  box-shadow: 0 0 8px var(--danger);
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

.recorder-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mic-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--text-secondary);
}
.mic-select-wrap select {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  max-width: 200px;
  outline: none;
  cursor: pointer;
}

.visualizer-wrap {
  position: relative;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 90px;
  margin-bottom: 14px;
}
#visualizerCanvas { width: 100%; height: 100%; display: block; }

.rec-timer {
  position: absolute;
  top: 8px;
  right: 10px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(10,15,30,0.7);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  backdrop-filter: blur(4px);
}
.recorder-card.is-recording .rec-timer {
  color: var(--danger);
  border-color: rgba(239,68,68,0.4);
}

.recorder-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn-record {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 22px;
  border-radius: 99px;
  border: none;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(239,68,68,0.3);
  transition: all 0.15s ease;
}
.btn-record:hover { box-shadow: 0 6px 28px rgba(239,68,68,0.45); transform: translateY(-1px); }
.btn-record:active { transform: scale(0.97); }
.btn-record-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  transition: border-radius 0.15s;
}
.btn-record.recording {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.btn-record.recording .btn-record-circle {
  border-radius: 3px;
  background: #ef4444;
}

.recorder-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Review Stage ─── */
.review-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.review-preview-row audio {
  flex: 1;
  height: 36px;
  /* Dark audio player via color-scheme */
  color-scheme: dark;
}

.review-form { display: flex; flex-direction: column; gap: 12px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 150px;
}
.form-field.flex-1 { flex: 1; }
.form-field.flex-2 { flex: 1.5; }

.form-field label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.form-field input,
.form-field select {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field input:focus,
.form-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-field input::placeholder { color: var(--text-muted); }

.tag-suggestions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tag-suggestions-label { font-size: 11.5px; color: var(--text-muted); }

.tag-chips { display: flex; gap: 5px; flex-wrap: wrap; }

.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-secondary);
  border-radius: 99px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.chip-btn:hover { background: var(--surface-2); border-color: var(--primary-border); color: var(--text); }
.chip-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

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

/* ─── View Header ─── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.view-title-block {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.view-title-block h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}
.view-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

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

/* ─── Filter Bar ─── */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-box input::placeholder { color: var(--text-muted); }

.voice-filter-chips { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* ─── Clips Container ─── */
.clips-container { display: flex; flex-direction: column; gap: 6px; }

.clip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.clip-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.15s;
}
.clip-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateX(2px);
}
.clip-card.is-active {
  border-color: var(--primary-border);
  background: linear-gradient(135deg, var(--primary-soft), rgba(124,58,237,0.06));
  box-shadow: 0 0 20px var(--primary-glow);
}
.clip-card.is-active::before { background: var(--primary); }

.clip-order-num {
  width: 22px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.clip-play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.clip-play-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 16px var(--primary-glow);
}
.clip-card.is-active .clip-play-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 16px var(--primary-glow);
}

.clip-info { flex: 1; min-width: 0; }

.clip-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.clip-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.clip-meta-row {
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.clip-status-pill {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
}

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

.clip-action-btn {
  height: 30px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.14s;
}
.clip-action-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.clip-action-btn.loop-active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}
.clip-action-btn.icon-only {
  width: 30px;
  padding: 0;
  justify-content: center;
}
.clip-action-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}

/* ─── Empty State ─── */
.empty-state {
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  box-shadow: 0 0 24px var(--primary-glow);
}
.empty-state h3 { margin: 0; font-size: 17px; color: var(--text); }
.empty-state p {
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.5;
}

/* ─── Player Bar ─── */
.player-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: rgba(10, 15, 30, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

.player-top-progress {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  position: relative;
}
.progress-track { position: relative; width: 100%; height: 100%; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.08s linear;
}
.progress-pause-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 0%;
  background: var(--amber);
  transition: width 0.1s linear;
}

.player-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.player-now {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  max-width: 280px;
  flex: 1;
}

.eq-indicator {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding-bottom: 3px;
  flex-shrink: 0;
}
.eq-indicator span {
  width: 4px;
  height: 5px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: height 0.2s, background 0.2s;
}
.eq-indicator.playing span {
  background: var(--primary);
  animation: eqBounce 0.75s ease-in-out infinite;
}
.eq-indicator.playing span:nth-child(2) { animation-delay: 0.18s; }
.eq-indicator.playing span:nth-child(3) { animation-delay: 0.35s; }
.eq-indicator.waiting span { background: var(--amber); height: 9px; }

@keyframes eqBounce {
  0%, 100% { height: 5px; }
  50% { height: 18px; }
}

.player-now-text { min-width: 0; }
.player-title {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.player-meta {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-meta.is-waiting { color: var(--amber); font-weight: 600; }

/* ─── Transport ─── */
.player-transport { display: flex; align-items: center; gap: 6px; }

.transport-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.14s;
}
.transport-btn:hover { background: var(--surface-2); color: var(--text); }
.transport-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.transport-play {
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}
.transport-play:hover {
  background: var(--primary-hover);
  color: #fff;
  box-shadow: 0 0 28px rgba(59,130,246,0.4);
}

.player-time {
  margin-left: 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 72px;
}

/* ─── Player Settings ─── */
.player-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.repeat-segmented {
  display: inline-flex;
  background: rgba(0,0,0,0.3);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.14s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-glow);
}

.compact-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 12px;
  color: var(--text-muted);
}
.compact-control select {
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.compact-control.timer-active {
  background: var(--amber-soft);
  border-color: rgba(245,158,11,0.3);
  color: var(--amber);
}

.volume-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}
.volume-control input[type="range"] {
  width: 72px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(59,130,246,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-width 0.15s;
}
.modal-card.modal-card-wide { max-width: 700px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.checklist { display: flex; flex-direction: column; gap: 5px; max-height: 320px; overflow-y: auto; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  background: var(--surface-2);
}
.check-row:hover { background: var(--surface-3); border-color: var(--border-strong); }
.check-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.check-row-text { flex: 1; min-width: 0; }
.check-row-title { font-weight: 600; font-size: 14px; color: var(--text); }
.check-row-sub { font-size: 12px; color: var(--text-muted); }

/* ─── Trimmer ─── */
.trimmer-wrap { display: flex; flex-direction: column; gap: 14px; }

.trimmer-canvas-box {
  position: relative;
  height: 136px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: ew-resize;
}
.trimmer-canvas-box canvas { width: 100%; height: 100%; display: block; }

.trimmer-loading {
  height: 136px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}

.trimmer-times {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.trimmer-time-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.trimmer-time-group.right { justify-content: flex-end; }
.trimmer-time-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.trimmer-time-val {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: center;
  color: var(--text);
}

.nudge-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.nudge-btn:hover { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }

.trimmer-duration-pill {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 99px;
  padding: 5px 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.trimmer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.trimmer-toolbar-left,
.trimmer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.trimmer-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.trimmer-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ─── QR Modal ─── */
.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 20px;
}

.qr-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  width: 100%;
}

.qr-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.14s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qr-tab:hover { color: var(--text); }
.qr-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-glow);
}

.qr-canvas-wrap {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 0 40px rgba(59, 130, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  min-height: 200px;
}
.qr-canvas-wrap canvas,
.qr-canvas-wrap table {
  display: block;
}

.qr-url-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  width: 100%;
  max-width: 320px;
}
.qr-url-text {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  min-width: 0;
}
.qr-copy-btn {
  flex-shrink: 0;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.qr-copy-btn:hover { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }
.qr-copy-btn.copied { background: var(--success-soft); border-color: rgba(16,185,129,0.3); color: var(--success); }

.qr-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  margin: 0;
  max-width: 300px;
}

.qr-hint-warning {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  text-align: left;
  max-width: 320px;
}

.qr-no-lan {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 16px;
  line-height: 1.6;
}

/* ─── Toasts ─── */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: calc(var(--player-height) + 16px);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out;
  backdrop-filter: blur(8px);
}
.toast.error {
  background: var(--danger-soft);
  border-color: rgba(239,68,68,0.3);
  color: #fca5a5;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Mic Blocked Banner (e.g. iOS Lockdown Mode) ─── */
.mic-blocked-banner {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mic-blocked-title {
  font-size: 14px;
  font-weight: 700;
  color: #fbbf24;
}
.mic-blocked-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.mic-blocked-text strong {
  color: var(--text);
}
.mic-blocked-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

/* ─── Responsive ─── */
@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .sidebar { position: static; }
  .player-inner { padding: 10px 16px; }
  .app-shell { padding-bottom: 180px; }
  .brand-text p { display: none; }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .brand { gap: 8px; }
  .brand-icon svg { width: 32px; height: 32px; }
  .brand-text h1 { font-size: 16px; }
  .topbar-actions {
    width: 100%;
    gap: 6px;
  }
  .topbar-actions .btn {
    flex: 1;
    height: 36px;
    padding: 0 10px;
    font-size: 12.5px;
    min-width: 0;
  }
  .topbar-actions .btn span {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .recorder-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 170px;
  }
}
