/* =========================================================================
   Voz13 — hoja de estilos
   ========================================================================= */

:root {
  --bg: #0b0d13;
  --bg-soft: #11141d;
  --surface: rgba(23, 27, 38, 0.72);
  --surface-solid: #171b26;
  --surface-hi: rgba(38, 44, 60, 0.75);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.16);
  --text: #e8eaf0;
  --text-soft: #a2a9bb;
  --text-dim: #6f7789;
  --accent: #7aa2ff;
  --accent-2: #b58cff;
  --accent-3: #ff8fb1;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #fb7185;
  --grad: linear-gradient(120deg, #7aa2ff 0%, #b58cff 50%, #ff8fb1 100%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f6f7fb;
    --bg-soft: #ffffff;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-solid: #ffffff;
    --surface-hi: rgba(240, 242, 248, 0.9);
    --border: rgba(16, 20, 32, 0.09);
    --border-hi: rgba(16, 20, 32, 0.18);
    --text: #171b26;
    --text-soft: #4c5566;
    --text-dim: #7b839a;
    --accent: #3b6df0;
    --accent-2: #8b5cf6;
    --accent-3: #ec4899;
    --shadow: 0 18px 44px rgba(20, 25, 45, 0.12);
  }
  /* Sobre fondo claro los halos de color deslucen el texto: los bajamos. */
  :root:not([data-theme='dark']) .aurora span { opacity: 0.13; }
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganar siempre: varios bloques llevan display: flex/grid
   y sin esto seguirian ocupando sitio (y tapando clics) al ocultarlos. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ------------------------------- Fondo ---------------------------------- */

.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.aurora span {
  position: absolute;
  width: 46vw;
  height: 46vw;
  min-width: 320px;
  min-height: 320px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.28;
  animation: float 22s ease-in-out infinite;
}
.aurora span:nth-child(1) { background: #7aa2ff; top: -14%; left: -8%; }
.aurora span:nth-child(2) { background: #b58cff; top: 22%; right: -12%; animation-delay: -7s; }
.aurora span:nth-child(3) { background: #ff8fb1; bottom: -20%; left: 28%; animation-delay: -14s; }

@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(3%, 5%, 0) scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .aurora span { animation: none; }
  html { scroll-behavior: auto; }
}

/* ------------------------------ Cabecera -------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 32px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--grad);
  color: #0b0d13;
  flex-shrink: 0;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p { margin: 0; font-size: 12px; color: var(--text-dim); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-soft);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); background: var(--surface-hi); }
.tab.is-active { color: var(--text); background: var(--surface-hi); box-shadow: inset 0 0 0 1px var(--border-hi); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.status-pill:hover { border-color: var(--border-hi); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.dot.err { background: var(--err); box-shadow: 0 0 10px var(--err); }
.dot.busy { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }

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

/* ------------------------------ Estructura ------------------------------ */

.shell { max-width: 1420px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 32px) 140px; }

.panel { display: none; animation: rise 0.28s ease; }
.panel.is-active { display: block; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 20px; align-items: start; }
.col-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col-side { position: sticky; top: 92px; }
.config-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 20px; }

@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr; }
  .col-side { position: static; }
}

/* ------------------------ Asistente de configuración --------------------- */

.setup {
  margin-bottom: 20px;
  padding: 20px;
  background: color-mix(in srgb, var(--warn) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.3s ease;
}

.setup-head { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 18px; flex-wrap: wrap; }
.setup-head > div { flex: 1; min-width: 220px; }
.setup-head h2 { margin: 0 0 3px; font-size: 16px; font-weight: 600; }
.setup-head p { margin: 0; font-size: 13px; color: var(--text-soft); }
.setup-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); flex-shrink: 0; }
.setup-icon svg { width: 19px; height: 19px; }

.setup-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.setup-col { padding: 16px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.setup-col h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.setup-col h3 em { font-style: normal; font-size: 12px; font-weight: 400; color: var(--text-dim); }
.setup-col .step { display: grid; place-items: center; width: 21px; height: 21px; font-size: 12px; font-weight: 700; color: #0b0d13; background: var(--grad); border-radius: 7px; }

.setup-note { margin: 8px 0 0; font-size: 12px; line-height: 1.55; color: var(--text-dim); }
.setup-warn { margin: 10px 0 0; padding: 9px 11px; font-size: 11.5px; line-height: 1.5; color: var(--text-soft); background: color-mix(in srgb, var(--warn) 10%, transparent); border-radius: 8px; }

.envlist { margin: 12px 0 0; padding: 0; list-style: none; }
.envlist li { padding: 10px 0; border-top: 1px solid var(--border); }
.envlist li:first-child { border-top: 0; padding-top: 0; }
.envlist li.is-optional { opacity: 0.75; }
/* La variable que esta bloqueando la conexion: hay que verla antes que nada. */
.envlist li.is-urgent {
  padding: 12px;
  margin: 0 0 4px;
  border: 1px solid color-mix(in srgb, var(--err) 45%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--err) 10%, transparent);
}
.envlist li.is-urgent + li { border-top: 0; }
.envlist .setup-note { margin-top: 6px; }

/* Columna desactivada (por ejemplo, claves del navegador que el backend no acepta). */
.setup-col.is-disabled { opacity: 0.55; }
.setup-col.is-disabled input,
.setup-col.is-disabled button { cursor: not-allowed; }

.envrow { display: flex; align-items: center; gap: 8px; }
.envrow code {
  flex: 1; min-width: 0; padding: 7px 10px; font-family: var(--mono); font-size: 12px;
  color: var(--accent); background: var(--surface-hi); border-radius: 8px;
  overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.envrow code::-webkit-scrollbar { display: none; }
.envrow button { flex-shrink: 0; }
.envvalue { margin-top: 6px; }
.envvalue code { color: var(--ok); font-size: 11.5px; }

/* ------------------------------ Diagnóstico ------------------------------ */

.check { display: flex; gap: 11px; padding: 11px 0; border-top: 1px solid var(--border); }
.check:first-child { border-top: 0; padding-top: 0; }
.check-mark {
  display: grid; place-items: center; width: 21px; height: 21px; flex-shrink: 0;
  font-size: 12px; font-weight: 700; border-radius: 50%; margin-top: 1px;
}
.check.is-ok .check-mark { color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
.check.is-bad .check-mark { color: var(--err); background: color-mix(in srgb, var(--err) 16%, transparent); }
.check.is-warn .check-mark { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.check-body { min-width: 0; }
.check-body b { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.check-body p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--text-soft); overflow-wrap: anywhere; }
.check-fix { margin-top: 5px !important; color: var(--accent) !important; }

/* -------------------------------- Tarjetas ------------------------------ */

.card {
  padding: 20px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; color: var(--text-soft); }
.card-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* -------------------------------- Editor -------------------------------- */

.editor {
  width: 100%;
  min-height: 300px;
  padding: 16px 18px;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.editor:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.editor::placeholder { color: var(--text-dim); }

.tagbar { margin-top: 14px; }
.tagbar-label { display: block; margin-bottom: 8px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-dim); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips button {
  padding: 6px 12px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-soft);
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s;
}
.chips button:hover { color: var(--text); border-color: var(--border-hi); transform: translateY(-1px); }
.chips button.is-active { color: #0b0d13; background: var(--grad); border-color: transparent; font-weight: 600; }

.meter-row { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.meter { font-size: 12.5px; color: var(--text-dim); }
.meter b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.meter-quota { margin-left: auto; }

/* ------------------------------- Campos --------------------------------- */

.field { margin-bottom: 16px; }
/* Los grupos de botones llevan un <span class="label"> en vez de un <label for>,
   porque "for" solo asocia con controles de formulario. Mismo aspecto. */
.field > label,
.field > .label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-soft);
}
.field output { font-family: var(--mono); font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }

select, input[type='url'], input[type='text'], input[type='password'], input[type='number'], input[type='search'], input[type='file'] {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a2a9bb' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
select:focus, input:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
input[type='file'] { padding: 9px 12px; cursor: pointer; }
input[type='file']::file-selector-button {
  margin-right: 10px; padding: 5px 12px; font: inherit; font-size: 12.5px;
  color: var(--text); background: var(--surface-hi); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
}

.hint { margin: 6px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--text-dim); }

/* La linea de tiempo del montaje: una fila por plano, y se lee de un vistazo si algo
   dura lo que no debe. Con scroll propio, que un documental largo son cien filas. */
.mono-block {
  margin: 0;
  padding: 10px 12px;
  max-height: 340px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  background: var(--bg-soft, rgba(0, 0, 0, .18));
  border: 1px solid var(--border, rgba(255, 255, 255, .08));
  border-radius: 8px;
  white-space: pre;
}
.notice { margin: 0 0 14px; padding: 11px 13px; font-size: 12.5px; line-height: 1.55; color: var(--text-soft); background: color-mix(in srgb, var(--warn) 9%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent); border-radius: 10px; }

.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field input { flex: 1; min-width: 0; }
.inline-field span { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: var(--surface-hi); border-radius: 999px; outline: none; padding: 0; border: 0; }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--grad); cursor: pointer; border: 2px solid var(--bg); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
input[type='range']::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #7aa2ff; cursor: pointer; border: 2px solid var(--bg); }

.segmented { display: flex; gap: 3px; padding: 3px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 11px; }
.segmented.wide { width: 100%; margin-bottom: 16px; }
.segmented button {
  flex: 1; padding: 8px 10px; font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--text-soft); background: none; border: 0; border-radius: 8px; cursor: pointer;
  transition: all 0.16s; white-space: nowrap;
}
.segmented button:hover { color: var(--text); background: var(--surface-hi); }
.segmented button.is-active { color: var(--text); background: var(--surface-hi); box-shadow: inset 0 0 0 1px var(--border-hi); }

/* Selector rapido de idioma: dos habituales, deteccion y "Otro..." que abre la lista. */
.segmented.lang { flex-wrap: wrap; margin-bottom: 8px; }
.segmented.lang button { flex: 1 1 auto; min-width: 64px; padding: 8px 9px; font-size: 12px; }
.segmented.lang + select { margin-top: 2px; }

.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13px; color: var(--text-soft); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: relative; width: 38px; height: 21px; background: var(--surface-hi); border: 1px solid var(--border); border-radius: 999px; transition: background 0.2s; flex-shrink: 0; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--text-dim); transition: transform 0.2s, background 0.2s; }
.switch input:checked + span { background: color-mix(in srgb, var(--accent) 32%, transparent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.switch input:checked + span::after { transform: translateX(17px); background: var(--accent); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

.advanced { margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--border); }
.advanced summary { font-size: 12.5px; font-weight: 500; color: var(--text-soft); cursor: pointer; list-style: none; padding: 4px 0; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: '▸ '; color: var(--text-dim); }
.advanced[open] summary::before { content: '▾ '; }
.advanced > *:not(summary) { margin-top: 14px; }

/* -------------------------------- Botones ------------------------------- */

button.primary, button.secondary, button.danger, button.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; font: inherit; font-size: 14px; font-weight: 600;
  border-radius: 12px; cursor: pointer; border: 1px solid transparent;
  transition: transform 0.14s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
  white-space: nowrap;
}
button.primary svg, button.secondary svg, button.danger svg, button.ghost svg { width: 17px; height: 17px; flex-shrink: 0; }
button.primary { color: #0b0d13; background: var(--grad); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 28%, transparent); }
button.secondary { color: var(--text); background: var(--surface-hi); border-color: var(--border); }
button.danger { color: #fff; background: linear-gradient(120deg, #f43f5e, #fb7185); }
button.ghost { padding: 6px 12px; font-size: 12.5px; font-weight: 500; color: var(--text-soft); background: var(--surface-hi); border-color: var(--border); }
button.sm { padding: 8px 14px; font-size: 12.5px; }
button.primary:hover, button.secondary:hover, button.danger:hover, button.ghost:hover { transform: translateY(-1px); }
button.ghost:hover { color: var(--text); border-color: var(--border-hi); }
button:disabled { opacity: 0.42; cursor: not-allowed; transform: none !important; box-shadow: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; color: var(--text-soft); background: var(--surface-hi); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--text); border-color: var(--border-hi); }

.actionbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 10px; max-width: calc(100vw - 32px); flex-wrap: wrap; justify-content: center;
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  backdrop-filter: blur(18px); border: 1px solid var(--border-hi);
  border-radius: 18px; box-shadow: var(--shadow);
}
.save-group { display: flex; align-items: stretch; }
.save-group button { border-radius: 12px 0 0 12px; }
.save-format { width: auto; min-width: 74px; border-radius: 0 12px 12px 0; border-left: 0; background-color: var(--surface-hi); }

/* ------------------------------ Voz elegida ----------------------------- */

.voice-card {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 18px;
  padding: 13px 14px; font: inherit; text-align: left; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color 0.18s, transform 0.14s;
}
.voice-card:hover { border-color: var(--border-hi); transform: translateY(-1px); }
.voice-card > svg { width: 18px; height: 18px; margin-left: auto; color: var(--text-dim); flex-shrink: 0; }
.voice-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #0b0d13; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.voice-info { display: flex; flex-direction: column; min-width: 0; }
.voice-info b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-info small { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------- Progreso ------------------------------- */

.progress { margin-bottom: 16px; }
.progress-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12.5px; color: var(--text-soft); }
.progress-head span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.progress-track { height: 6px; background: var(--surface-hi); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--grad); border-radius: 999px; transition: width 0.35s ease; }
.progress-note { margin: 8px 0 0; font-size: 11.5px; color: var(--text-dim); }

.player { display: flex; flex-direction: column; gap: 10px; }
.player audio { width: 100%; height: 40px; }
.player-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.empty { margin: 0; padding: 22px 0; font-size: 13.5px; color: var(--text-dim); text-align: center; }
.empty b { color: var(--text-soft); }

.parts { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.parts summary { font-size: 12.5px; color: var(--text-soft); cursor: pointer; }
.parts-list { max-height: 280px; margin: 12px 0 0; padding: 0 0 0 4px; overflow-y: auto; list-style: none; }
.parts-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 12.5px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 9px; }
.parts-list .idx { font-family: var(--mono); font-size: 11px; color: var(--text-dim); min-width: 34px; }
.parts-list .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.parts-list .st { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.parts-list .st.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.parts-list .st.err { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.parts-list .st.pending { color: var(--text-dim); background: var(--surface-hi); }
/* Lo que no llego a empezar porque se cancelo: apagado, ni error ni en curso. */
.parts-list .st.cancel { color: var(--text-dim); background: transparent; border: 1px dashed var(--border); }
/* El que si salio y se corto a mitad: pudo contar en la cuota, asi que se ve. */
.parts-list .st.cut { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

.badge { padding: 1px 8px; margin-left: 6px; font-size: 11px; font-family: var(--mono); color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 999px; }

/* ----------------------------- Transcripción ---------------------------- */

.levels { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.level-bar { flex: 1; height: 5px; background: var(--surface-hi); border-radius: 999px; overflow: hidden; }
.level-bar div { height: 100%; width: 0; background: var(--grad); border-radius: 999px; transition: width 0.08s linear; }
.levels span { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }

.rec-timer { font-family: var(--mono); font-size: 13px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.rec-timer.is-rec { color: var(--err); }

.transcript {
  min-height: 340px; max-height: 58vh; overflow-y: auto; padding: 6px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  scroll-behavior: smooth;
}
.seg { display: flex; gap: 12px; padding: 9px 12px; border-radius: 9px; animation: rise 0.22s ease; }
.seg:hover { background: var(--surface-hi); }
.seg time { font-family: var(--mono); font-size: 11px; color: var(--text-dim); padding-top: 3px; min-width: 62px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.seg p { margin: 0; font-size: 14.5px; line-height: 1.65; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.seg.is-pending p { color: var(--text-dim); font-style: italic; }
/* Un hueco sin voz NO es un bloque en proceso. Compartian la clase is-pending, y un
   silencio se leia como "esto todavia esta trabajando". Se parecen en el gris, pero
   uno termina y el otro ya termino. */
.seg.is-quiet p { color: var(--text-dim); font-style: italic; opacity: 0.75; }
.seg.is-error p { color: var(--err); font-size: 13px; }
.seg .spk { font-size: 11px; font-weight: 600; color: var(--accent); display: block; }

/* --------------------------------- Modal -------------------------------- */

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 6, 12, 0.72); backdrop-filter: blur(6px); }
.modal-box {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  width: min(1080px, 100%); max-height: min(86vh, 860px); padding: 22px;
  background: var(--surface-solid); border: 1px solid var(--border-hi);
  border-radius: 22px; box-shadow: var(--shadow); animation: rise 0.24s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--text-dim); }

.voice-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.voice-filters input[type='search'] { grid-column: 1 / -1; }

.voice-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 10px;
  flex: 1; overflow-y: auto; padding: 4px; margin: -4px;
}
/* La tarjeta solo enmarca: dentro van dos botones hermanos, elegir y escuchar.
   Ninguno cuelga del otro, que es lo que dejaba mudo al de la muestra. */
.voice-item {
  position: relative; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 14px;
  transition: border-color 0.16s, transform 0.14s;
}
.voice-item:hover { border-color: var(--border-hi); transform: translateY(-2px); }
.voice-item.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
/* El hueco de la derecha es para el botón de escuchar, que va encima. */
.voice-pick {
  display: flex; flex-direction: column; gap: 8px; width: 100%;
  padding: 13px; padding-right: 51px; text-align: left;
  font: inherit; color: var(--text); background: none; border: 0;
  border-radius: 14px; cursor: pointer;
}
.voice-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.voice-item-top { display: flex; align-items: center; gap: 10px; }
.voice-item-top .voice-avatar { width: 34px; height: 34px; font-size: 14px; border-radius: 10px; }
.voice-item-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-play { position: absolute; top: 13px; right: 13px; display: grid; place-items: center; width: 28px; height: 28px; color: var(--text-soft); background: var(--surface-hi); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.voice-play svg { width: 13px; height: 13px; }
.voice-play:hover { color: var(--accent); }
.voice-desc { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.voice-labels { display: flex; flex-wrap: wrap; gap: 5px; }
.voice-labels span { padding: 2px 8px; font-size: 10.5px; color: var(--text-soft); background: var(--surface-hi); border-radius: 999px; }
.voice-labels span.pro { color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 15%, transparent); }

.skeleton { height: 108px; border-radius: 14px; background: linear-gradient(90deg, var(--bg-soft) 25%, var(--surface-hi) 50%, var(--bg-soft) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ------------------------------- Ajustes -------------------------------- */

.server-status { font-size: 12.5px; line-height: 1.7; color: var(--text-soft); }
.server-status .row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.server-status .row:last-child { border-bottom: 0; }
.server-status .row b { font-weight: 500; color: var(--text-dim); }
.server-status code { font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
.account-box { margin-bottom: 14px; }
.account-bar { height: 6px; margin: 10px 0 6px; background: var(--surface-hi); border-radius: 999px; overflow: hidden; }
.account-bar div { height: 100%; background: var(--grad); border-radius: 999px; }

/* -------------------------------- Avisos -------------------------------- */

.toasts { position: fixed; right: 16px; bottom: 96px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 15px;
  font-size: 13px; line-height: 1.5; color: var(--text);
  background: var(--surface-solid); border: 1px solid var(--border-hi);
  border-left: 3px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow);
  animation: slide 0.26s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
.toast.is-out { animation: fade 0.26s ease forwards; }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes fade { to { opacity: 0; transform: translateX(24px); } }

/* ------------------------------- Pantallas ------------------------------ */

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .topbar { gap: 12px; padding: 12px 16px; }
  .brand-text p { display: none; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .tab { flex: 1; justify-content: center; }
  .shell { padding: 18px 16px 170px; }
  .card { padding: 16px; }
  .actionbar { left: 16px; right: 16px; transform: none; max-width: none; }
  .actionbar button { flex: 1; }
  .save-group { flex: 1 1 100%; }
  .save-group button { flex: 1; }
  .modal-box { padding: 16px; max-height: 92vh; }
  .seg time { min-width: 54px; }
  .toasts { right: 12px; left: 12px; bottom: 176px; max-width: none; }
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-hi); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); background-clip: content-box; }

/* --------------------------- El botón flotante ---------------------------- */
/*
 * Las opciones de estilo del montaje. Van flotando y no en la columna porque se tocan
 * DESPUÉS de ver cómo queda: tenerlas arriba con el resto de campos obligaba a subir,
 * cambiar y volver a bajar en cada vuelta.
 *
 * `sticky` y no `fixed`: con `fixed` el panel se queda encima del vídeo del resultado y
 * tapa justo lo que se está mirando.
 */
.flotante {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin: 12px 0;
  pointer-events: none;
}

.flotante > * {
  pointer-events: auto;
}

.flotante > button {
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.flotante-panel {
  width: min(360px, 100%);
  padding: 14px 16px;
  border: 1px solid var(--linea, #2a2f3a);
  border-radius: 12px;
  background: var(--fondo-2, #161a22);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.flotante-panel .field + .field {
  margin-top: 12px;
}

/* ------------------------------- El documental ----------------------------- */
/*
 * La pantalla que se usa. Una columna estrecha de mensajes y, debajo, dos archivos y un
 * boton: no hay tarjetas, ni rejillas, ni paneles de mandos. Lo que se mira durante
 * horas tiene que poder mirarse durante horas.
 */

#panel-doc {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  /* La altura de la ventana menos la cabecera: el compositor se queda abajo y los
     mensajes corren por dentro, como en cualquier conversacion. Con la pagina entera
     creciendo, cada mensaje nuevo movia el boton de sitio. */
  min-height: calc(100vh - 170px);
}

.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 2px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.chat:empty::after {
  /* Lo que cuesta, dicho donde se lee: es la unica pantalla que hay y el boton no
     vuelve a preguntar. Un aviso aparte seria una cosa mas que tocar. */
  content: 'Suelta la guía y la voz, y pulsa. De ahí sale el documental entero, solo y hasta el vídeo: cuesta dinero y no vuelve a preguntar.';
  color: var(--text-dim);
  font-size: 14px;
  margin: auto;
  text-align: center;
  max-width: 40ch;
  line-height: 1.6;
}

.msg { display: flex; flex-direction: column; gap: 4px; }
.msg .quien {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.msg .dice {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  /* Los avisos vienen en varias lineas y se respetan: meterlos todos en un parrafo
     seguido es la diferencia entre una lista y un ladrillo. */
  white-space: pre-line;
}
.msg.mio { align-items: flex-end; }
.msg.mio .dice { color: var(--text-soft); }

/* El reloj de lo que se esta esperando. Vacio no ocupa nada --no hay :empty que valga
   con un span sin contenido dentro de un flex con gap-- asi que se apaga a mano. */
.msg .reloj {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.msg .reloj:empty { display: none; }

/* El punto que late mientras algo esta en marcha. Generar trescientas fuentes son horas,
   y una pantalla quieta durante horas se lee como una pantalla colgada. */
.msg.vivo .quien::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  animation: latir 1.4s ease-in-out infinite;
}
@keyframes latir { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

.video-chat {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  display: block;
  margin-bottom: 10px;
}

/* -- El compositor --------------------------------------------------------- */

.compositor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.compositor:focus-within { border-color: var(--border-hi); }

.instrucciones {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  outline: none;
  /* Crece con lo que se escriba, hasta un tope: una caja de texto que se come la
     pantalla tapa justo lo que se estaba leyendo. */
  min-height: 26px;
  max-height: 160px;
  overflow-y: auto;
}
.instrucciones::placeholder { color: var(--text-dim); }

.compositor-barra { display: flex; align-items: center; gap: 8px; }
.compositor-barra .crece { flex: 1 1 auto; }

.adjunto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.adjunto:hover { border-color: var(--border-hi); color: var(--text); }
.adjunto svg { width: 15px; height: 15px; }
/* El input de verdad no se ve, pero SIGUE EXISTIENDO: es el que abre el selector, el
   que lleva los archivos y el que miran las pruebas. Con `display:none` hay navegadores
   que no lo dejan enfocar. */
.adjunto input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.adjunto.puesto { border-color: var(--accent); color: var(--text); }

.adjuntos { list-style: none; padding: 0; margin: 8px 2px 0; }
#panel-doc > .hint { margin: 6px 2px 0; }

@media (max-width: 640px) {
  #panel-doc { min-height: calc(100vh - 130px); }
  .compositor-barra { flex-wrap: wrap; }
  .compositor-barra .crece { display: none; }
  .compositor-barra .primary { width: 100%; }
}
