:root {
  --bg: #0f1115; --card: #171a21; --line: #262b35; --text: #e8eaee; --muted: #8b93a3;
  --accent: #3fb6a8; --accent2: #2a8f84; --danger: #e5484d; --warn: #f0b429; --ok: #3fb950;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
code { background: #222733; padding: 1px 5px; border-radius: 4px; }

/* ---------- Panel de control ---------- */
.panel header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 30px; height: 30px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.version { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; font-variant-numeric: tabular-nums; }
.version.new { color: var(--warn); border-color: #6b5520; cursor: pointer; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.chip.ok { color: var(--ok); border-color: #2b5d35; }
.chip.warn { color: var(--warn); border-color: #6b5520; }
.chip.bad { color: var(--danger); border-color: #6b2a2c; }
main { max-width: 1100px; margin: 0 auto; padding: 18px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 18px; align-items: end; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.inline, label.row-check { flex-direction: row; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 6px; }
input, select, textarea, button { font: inherit; color: var(--text); }
input:not([type]), input[type=text], select, textarea {
  background: #0f1218; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
textarea { resize: vertical; font-family: ui-monospace, monospace; font-size: 13px; }
input[type=range] { accent-color: var(--accent); }
button { background: #222733; border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; font-weight: 600; }
button.danger { background: #3a1d20; border-color: #5c2a2e; }
button.ghost { background: transparent; }
.big-btn { padding: 11px 22px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.card .controls:first-of-type { margin-top: 0; }
.timer { font-variant-numeric: tabular-nums; font-size: 20px; margin-left: 8px; }
#queueInfo { font-size: 12px; } #queueInfo.bad { color: var(--warn); }
.meter { height: 10px; background: #0f1218; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; align-self: center; }
#meterBar { height: 100%; width: 0; background: #4b5565; transition: width .1s; }
#meterBar.speaking { background: var(--ok); }
.progress { position: relative; margin-top: 14px; height: 26px; background: #0f1218; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: var(--accent2); transition: width .3s; }
#progressText { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 10px; font-size: 12px; }
details { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.log { max-height: 320px; overflow: auto; margin-top: 8px; }
.log .row { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log .ts { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .src { color: var(--muted); } .log .tgt { margin-top: 2px; }
.sessions { display: grid; gap: 10px; }
.session { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.session .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.session .actions button { font-size: 13px; padding: 7px 10px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; margin-left: 6px; }
.tag.rec { background: #3a1d20; color: #ff8a8d; } .tag.warn { background: #3b3216; color: var(--warn); }
footer { text-align: center; font-size: 12px; padding: 20px; }

/* ---------- Subtítulos (vista previa y proyector) ---------- */
.captions { --size: 7vh; background: #000; color: #fff; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.captions.light { background: #fff; color: #000; }
/* Ventana de 3 líneas; el texto va abajo y sube suavemente */
.captions .flow { position: relative; overflow: hidden; height: calc(var(--size) * 1.3 * 3); flex: none; }
.captions .text { position: absolute; left: 0; right: 0; top: 0; font-size: var(--size); line-height: 1.3; font-weight: 600; will-change: transform; }
.captions .w { transition: opacity .35s ease-out; }
.captions .w.new { opacity: 0; }
.captions .orig { display: none; font-size: calc(var(--size) * .45); opacity: .6; margin-top: .6em; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.captions.show-orig .orig { display: block; }
.preview { height: 220px; border-radius: 8px; padding: 14px 18px; }
body.display { height: 100vh; overflow: hidden; }
body.display .captions { height: 100vh; padding: 4vh 5vw; }
.hint { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(40,40,40,.85); color: #ddd;
  font-size: 13px; padding: 6px 14px; border-radius: 99px; transition: opacity .4s; pointer-events: none; }

.hint-box { margin: 12px 0 0; font-size: 13px; color: var(--muted); background: #0f1218; border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }
.engine-status { font-size: 14px; padding: 10px 12px; border-radius: 8px; background: #0f1218; border: 1px solid var(--line); margin-bottom: 14px; }
.engine-status.ok { border-color: #2b5d35; color: #b8f0c2; }
.engine-status.info { border-color: #2a4b6b; color: #c4dcf5; }
.install p { font-size: 13px; line-height: 1.5; }
.cmd { display: flex; gap: 8px; align-items: stretch; }
.cmd code { flex: 1; display: block; padding: 10px; overflow-x: auto; white-space: nowrap; font-size: 12px; }
#advanced, #installBox { margin-top: 14px; }
