/* Mobile-first, pantalla oscura pensada para transmitir de noche sin deslumbrar. */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f14;
  --panel: #171a22;
  --panel2: #1f2430;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #e0245e;
  --ok: #2ecc71;
  --warn: #f1c40f;
  --err: #e74c3c;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px calc(76px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
}
.brand { font-weight: 800; letter-spacing: 2px; font-size: 15px; color: var(--muted); }

.live-badge { font-weight: 700; color: var(--accent); font-size: 15px; }
.live-badge b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 4px; }

/* ── Preview ── */
.preview-wrap {
  position: relative;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 9 / 16;
  max-height: 52dvh;
  margin: 0 auto;
  width: 100%;
  max-width: calc(52dvh * 9 / 16);
}
#preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-msg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; text-align: center; padding: 20px;
}
.preview-controls {
  position: absolute; bottom: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 12px;
}
.chip {
  background: rgba(23, 26, 34, .85);
  color: var(--text);
  border: 1px solid #2c3242;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
}
.chip.off { color: var(--err); text-decoration: line-through; }
.chip-danger { color: var(--err); }

/* ── Plataformas ── */
.platforms { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.platforms li {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 14px;
}
.platforms input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.platforms .pname { flex: 1; font-weight: 600; text-transform: capitalize; }
.platforms .pstate { font-size: 13px; color: var(--muted); text-align: right; }
.platforms .pstate.live { color: var(--ok); font-weight: 700; }
.platforms .pstate.error { color: var(--err); font-weight: 700; }
.platforms .pstate.connecting { color: var(--warn); }
.platforms li.nokey { opacity: .55; }

/* ── Estado del sistema ── */
.sysstatus {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
}
.sysstatus b { color: var(--text); margin-left: 4px; }

/* ── Botones ── */
button { cursor: pointer; font-family: inherit; }
.btn-primary, .btn-go, .btn-stop {
  border: 0; border-radius: 14px;
  padding: 16px;
  font-size: 17px; font-weight: 800; letter-spacing: 1px;
  width: 100%;
  color: #fff;
}
.btn-primary { background: #2d6cdf; }
.btn-go { background: var(--accent); box-shadow: 0 0 24px rgba(224, 36, 94, .45); }
.btn-stop { background: #3a4152; }
button:disabled { opacity: .5; }

/* ── Avisos ── */
.warning {
  background: #3c320e;
  color: #ffd75e;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
}
.error { color: var(--err); font-size: 14px; text-align: center; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ── Login ── */
.login-box {
  margin-top: 18dvh;
  display: flex; flex-direction: column; gap: 20px; text-align: center;
}
.login-box h1 { letter-spacing: 6px; font-size: 26px; }
.login-box form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="password"], input[type="url"] {
  background: var(--panel2);
  border: 1px solid #2c3242;
  border-radius: 10px;
  color: var(--text);
  padding: 13px;
  font-size: 16px; /* evita el zoom automático de iOS */
  width: 100%;
}

/* ── Configuración ── */
.cfg-card {
  background: var(--panel);
  border-radius: 14px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 12px;
}
.cfg-card h2 { font-size: 16px; text-transform: capitalize; }
.cfg-card .masked { font-size: 12px; color: var(--muted); word-break: break-all; }
.cfg-actions { display: flex; gap: 8px; }
.cfg-actions button {
  flex: 1; border: 0; border-radius: 10px; padding: 12px;
  font-size: 14px; font-weight: 700; color: #fff;
}
.cfg-save { background: #2d6cdf; }
.cfg-test { background: #3a4152; }
.cfg-msg { font-size: 12px; min-height: 14px; }
.cfg-msg.ok { color: var(--ok); }
.cfg-msg.err { color: var(--err); }

/* ── Biblioteca multimedia ── */
.media-section {
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.media-section h2 {
  font-size: 15px;
  display: flex; align-items: center; justify-content: space-between;
}
.btn-upload {
  background: #2d6cdf; color: #fff;
  border: 0; border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px; font-weight: 700;
}
.media-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.media-list li {
  background: var(--panel2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.media-list .minfo { flex: 1; min-width: 0; }
.media-list .mname {
  font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-list .mmeta { font-size: 11px; color: var(--muted); }
.media-list .mact {
  background: none; border: 0;
  font-size: 17px;
  padding: 6px;
  color: var(--text);
}
.media-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }

/* ── Barra de uso / progreso de subida ── */
.usage-bar {
  position: relative;
  background: var(--panel2);
  border-radius: 8px;
  height: 22px;
  overflow: hidden;
}
.usage-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 0%;
  background: #2d6cdf;
  transition: width .3s;
}
.usage-bar span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text);
}
.upload-progress { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* ── Modal de preview ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .85);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-body {
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 12px;
}
#modal-content img, #modal-content video {
  width: 100%; max-height: 65dvh;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
}
#modal-content audio { width: 100%; }

/* ── Tab bar ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--panel);
  border-top: 1px solid #2c3242;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1;
  background: none; border: 0;
  color: var(--muted);
  padding: 14px 0;
  font-size: 13px; font-weight: 600;
}
.tabbar button.active { color: var(--text); }
