/* ═══ Components — ElevenLabs compact ═══ */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.episodes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-5); }

.episode-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.episode-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  transform: translateY(-2px);
}
.episode-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }

.episode-card-cover {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: var(--elevated); flex-shrink: 0;
  isolation: isolate;
}
.episode-card-cover::after {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, rgba(0,0,0,0.4) 0%, transparent 48%);
  pointer-events: none; opacity: 0.9;
}
.episode-card-cover img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 0; }
.episode-card-cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--elevated);
}

.cover-play-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t-fast) var(--ease); z-index: 2;
}
.episode-card:hover .cover-play-overlay { opacity: 1; }
.cover-play-btn {
  width: 48px; height: 48px; border-radius: 50%; background: var(--black); color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center; transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.episode-card:hover .cover-play-btn { transform: scale(1.05); }
.cover-play-btn:hover { background: #292929; }
.cover-play-btn svg { width: 24px; height: 24px; }

.playing-bars {
  position: absolute; bottom: 8px; right: 8px; z-index: 3; display: flex; align-items: flex-end; gap: 2px; height: 14px;
}
.playing-bars span { width: 3px; border-radius: 1px; background: var(--surface); opacity: 0.9; }
.playing-bars span:nth-child(1) { height: 8px; }
.playing-bars span:nth-child(2) { height: 14px; }
.playing-bars span:nth-child(3) { height: 10px; }
.playing-bars span:nth-child(4) { height: 12px; }

.episode-card-title-row {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  margin-bottom: 2px;
}
.episode-card-title-row .episode-card-title {
  flex: 1; min-width: 0; margin-bottom: 0;
}
.episode-download-inline {
  flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  background: var(--elevated); color: var(--text-muted);
  border: 1px solid var(--border);
  text-decoration: none; opacity: 0.65;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.episode-download-inline svg { width: 14px; height: 14px; }
.episode-card:hover .episode-download-inline { opacity: 0.95; }
.episode-download-inline:hover {
  opacity: 1;
  background: var(--surface);
  color: var(--accent);
  border-color: rgba(93, 121, 223, 0.35);
}
.episode-download-inline:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.episode-card-body {
  padding: var(--sp-4); flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-3);
}
.episode-card-title {
  margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--text);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.episode-card-meta {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap;
}
.episode-card-meta-primary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px;
  font-size: 13px; color: var(--text-2); line-height: 1.4; min-width: 0; flex: 1;
}
.episode-card-date { color: var(--text-muted); font-weight: 500; }
.episode-meta-sep { color: var(--text-muted); opacity: 0.65; user-select: none; }
.episode-meta-duration { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 500; }
.episode-meta-articles { color: var(--text-2); }
.episode-card-meta-badge { flex-shrink: 0; align-self: center; }

/* Tipo de episódio (Radio Glitch / Narração / Discussão / …) */
.episode-card-kind-row { margin-bottom: 2px; }
.episode-kind {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 5px 10px; border-radius: var(--r-full); line-height: 1; border: 1px solid transparent;
}
.episode-kind--radio_glitch {
  background: linear-gradient(135deg, #EDE9FE 0%, #DDD6FE 100%);
  color: #5B21B6; border-color: rgba(91, 33, 182, 0.2);
}
.episode-kind--narration {
  background: rgba(93, 121, 223, 0.12); color: #3D52B8; border-color: rgba(93, 121, 223, 0.25);
}
.episode-kind--interactive {
  background: rgba(16, 185, 129, 0.12); color: #047857; border-color: rgba(16, 185, 129, 0.25);
}
.episode-kind--manual {
  background: var(--elevated); color: var(--text-2); border-color: var(--border);
}
.episode-kind--generated {
  background: var(--bg); color: var(--text-muted); border-color: var(--border);
}
.modal-kind-row { margin-bottom: var(--sp-2); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: var(--r-full); padding: 2px 8px; font-size: 11px; font-weight: 500;
}
.badge-ready { background: rgba(16,185,120,0.1); color: #10B978; }
.badge-processing { background: rgba(243,111,28,0.1); color: #F36F1C; }
.badge-error { background: rgba(235,82,75,0.1); color: #EB524B; }
.badge-spin {
  width: 10px; height: 10px; border: 2px solid rgba(243,111,28,0.35); border-top-color: #F36F1C;
  border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0;
}

.skeleton {
  background: linear-gradient(90deg, var(--elevated) 25%, var(--border) 50%, var(--elevated) 75%);
  background-size: 400px 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: var(--r-md);
}
.skeleton-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
}
.skeleton-cover { width: 100%; aspect-ratio: 16 / 9; }
.skeleton-body { padding: var(--sp-3) var(--sp-4); flex: 1; }
.skeleton-line { height: 10px; margin-bottom: var(--sp-2); border-radius: var(--r-sm); }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-40 { width: 40%; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center; padding: var(--sp-5);
  opacity: 0; pointer-events: none; transition: opacity var(--t-normal) var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); width: 100%; max-width: 720px;
  max-height: 80vh; overflow-y: auto; transform: translateY(24px); transition: transform var(--t-normal) var(--ease);
  box-shadow: var(--shadow-lg);
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header { padding: var(--sp-6) var(--sp-6) 0; display: flex; gap: var(--sp-5); align-items: flex-start; }
.modal-cover, .modal-cover-placeholder {
  width: 100px; height: 100px; border-radius: var(--r-md); object-fit: cover; flex-shrink: 0; background: var(--elevated);
}
.modal-cover-placeholder { display: flex; align-items: center; justify-content: center; }
.modal-meta { flex: 1; min-width: 0; }
.modal-episode-label {
  font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--sp-2);
}
.modal-title { font-size: 1.125rem; font-weight: 600; line-height: 1.3; color: var(--text); margin-bottom: var(--sp-3); }
.modal-meta-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.modal-meta-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; background: var(--elevated); display: flex; align-items: center; justify-content: center;
  color: var(--text-2); flex-shrink: 0; transition: background var(--t-fast) var(--ease);
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-actions { padding: var(--sp-4) var(--sp-6); display: flex; gap: var(--sp-3); }
.btn-play-modal {
  background: var(--black); color: var(--text-inverse); border-radius: var(--r-md); padding: 10px 20px;
  font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: var(--sp-2); transition: background var(--t-fast) var(--ease);
}
.btn-play-modal:hover { background: #292929; }
.btn-download-modal {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-md); padding: 10px 20px; font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn-download-modal:hover { background: var(--elevated); border-color: var(--border-hover); color: var(--accent); }
.modal-actions .modal-action-btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  text-decoration: none; padding: 10px 20px; font-size: 14px; font-weight: 500;
  border-radius: var(--r-md); border: 1px solid var(--border); background: transparent; color: var(--text);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.modal-actions .modal-action-btn:hover { background: var(--elevated); border-color: var(--border-hover); }

/* Edit episode modal */
.edit-modal { max-width: 560px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.edit-modal-inner { display: flex; flex-direction: column; min-height: 0; }
.edit-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6) 0;
}
.edit-modal-title { font-size: 1.125rem; font-weight: 600; color: var(--text); }
.edit-modal-body {
  padding: var(--sp-4) var(--sp-6);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.edit-modal-body label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.edit-story-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.edit-story-text {
  width: 100%; padding: var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 13px; font-family: var(--font); line-height: 1.5; resize: vertical;
}
.edit-story-text:focus { border-color: var(--accent); outline: none; }
.edit-modal-actions {
  padding: var(--sp-4) var(--sp-6) var(--sp-6);
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  border-top: 1px solid var(--border);
}
.edit-error { padding: var(--sp-8); color: var(--error); text-align: center; }

.modal-divider { height: 1px; background: var(--border); margin: 0 var(--sp-6); }
.modal-script { padding: var(--sp-6); }
.modal-script-title {
  font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--sp-5);
}
.script-section { margin-bottom: var(--sp-6); }
.script-section-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: var(--sp-3); display: flex; align-items: center; gap: var(--sp-2);
}
.script-section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.script-text {
  font-size: 14px; color: var(--text-2); line-height: 1.75; background: var(--bg); border-radius: var(--r-md);
  padding: var(--sp-4); border: 1px solid var(--border);
}
.story-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); margin-bottom: var(--sp-3);
}
.story-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: var(--sp-2); }
.story-card-text { font-size: 13px; color: var(--text-2); line-height: 1.65; margin-bottom: var(--sp-2); }
.story-source { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

.modal-loading { padding: var(--sp-12) var(--sp-6); text-align: center; color: var(--text-muted); }
.modal-spinner {
  width: 32px; height: 32px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto var(--sp-3);
}

.empty-state {
  text-align: center; padding: var(--sp-12) var(--sp-5); color: var(--text-muted); grid-column: 1 / -1;
}
.empty-icon {
  width: 56px; height: 56px; background: var(--elevated); border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--sp-4);
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: var(--sp-2); }
.empty-desc { font-size: 13px; }

.voices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); }
.voice-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3); transition: border-color var(--t-fast) var(--ease);
}
.voice-card:hover { border-color: var(--border-hover); }
.voice-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 16px; background: var(--elevated); border: 1px solid var(--border);
}
.voice-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.voice-lang { font-size: 12px; color: var(--text-muted); }
.voice-desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }

@media (max-width: 768px) {
  .episodes-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .voices-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .episodes-grid { grid-template-columns: 1fr; }
  .voices-grid { grid-template-columns: 1fr; }
}

/* ═══ VoiceLab ═══ */
.voices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.voice-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  transition: border-color var(--t-fast) var(--ease);
}
.voice-card:hover { border-color: var(--border-hover); }
.voice-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px;
}
.voice-avatar.female { background: rgba(235,82,75,0.08); border: 1px solid rgba(235,82,75,0.15); }
.voice-avatar.male { background: rgba(93,121,223,0.08); border: 1px solid rgba(93,121,223,0.15); }
.voice-info { flex: 1; min-width: 0; }
.voice-name { font-size: 14px; font-weight: 600; }
.voice-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.voice-desc { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.voice-play-btn {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--elevated); color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.voice-play-btn:hover { background: var(--border); color: var(--text); }
.voice-play-btn.loading { opacity: 0.5; pointer-events: none; }
.voice-play-btn.playing { background: var(--accent); color: var(--text-inverse, #fff); }

/* Simulator */
.sim-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  margin-top: var(--sp-6);
}
.sim-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.sim-desc { font-size: 13px; color: var(--text-2); margin-bottom: var(--sp-5); }
.sim-lines { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.sim-line { display: flex; gap: var(--sp-2); align-items: center; }
.sim-line-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; border: 1px solid var(--border);
}
.sim-voice-select {
  width: 140px; padding: 8px 10px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 13px; font-family: var(--font); flex-shrink: 0;
}
.sim-voice-select:focus { border-color: var(--accent); outline: none; }
.sim-text-input {
  flex: 1; padding: 8px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 13px; font-family: var(--font);
}
.sim-text-input:focus { border-color: var(--accent); outline: none; }
.sim-text-input::placeholder { color: var(--text-muted); }
.sim-remove-btn {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.sim-remove-btn:hover { background: rgba(235,82,75,0.1); color: var(--error); }
.sim-actions { display: flex; gap: var(--sp-3); }
.btn-primary {
  background: var(--black, #1C1C1C); color: var(--text-inverse, #fff);
  border-radius: var(--r-md); padding: 10px 20px; font-size: 14px; font-weight: 500;
  transition: background var(--t-fast);
}
.btn-primary:hover { background: #292929; }
.btn-secondary {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-md); padding: 10px 20px; font-size: 14px; font-weight: 500;
  transition: background var(--t-fast);
}
.btn-secondary:hover { background: var(--elevated); }
.sim-status {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-top: var(--sp-4); font-size: 13px; color: var(--text-2);
}
.sim-result { margin-top: var(--sp-4); }
.sim-result audio { border-radius: var(--r-md); }

@media (max-width: 768px) { .sim-line { flex-wrap: wrap; } .sim-voice-select { width: 100%; } }

/* Botao "ancora do diario" nos cards de voz */
.voice-daily-btn {
  background: none;
  border: 1px solid var(--border, #3a3a3a);
  border-radius: 8px;
  color: var(--text-muted, #888);
  cursor: pointer;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  transition: all .15s;
}
.voice-daily-btn:hover { color: var(--text, #eee); border-color: var(--text-muted, #888); }
.voice-daily-btn.active {
  color: var(--accent, #ffd24a);
  border-color: var(--accent, #ffd24a);
  background: color-mix(in srgb, var(--accent, #ffd24a) 12%, transparent);
}

/* Player custom compartilhado (/app + studio) + slot de preview */
.mp { display: flex; align-items: center; gap: 8px; width: 100%; }
.mp-btn { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--accent-light, rgba(93,121,223,0.1)); color: var(--accent); }
.mp-btn:hover { filter: brightness(0.96); }
.mp-seek { flex: 1; height: 4px; accent-color: var(--accent); cursor: pointer; }
.mp-time { font-size: 11px; color: var(--text-muted); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.mp-speed { flex-shrink: 0; font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--elevated); border-radius: 4px; padding: 2px 6px; min-width: 30px; }
.mp-speed:hover { color: var(--text); }
.mp-dl { flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); background: var(--elevated); }
.mp-dl:hover { color: var(--accent); background: var(--accent-light, rgba(93,121,223,0.1)); }
.mp-audio { display: none; }
.studio-preview-slot { margin-top: 12px; }
.studio-preview-slot:empty { display: none; }
