:root {
  --fondo: #101418;
  --panel: #171c22;
  --linea: #2a333d;
  --texto: #e8edf2;
  --tenue: #8b9aa8;
  --acento: #3b82f6;
  --verde: #22c55e;
  --naranja: #f59e0b;
  --azul: #38bdf8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fondo); color: var(--texto);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-left) env(safe-area-inset-bottom) env(safe-area-inset-right);
}
#cabecera {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--linea); background: var(--panel);
}
.titulo { font-weight: 600; }
.estado { font-size: 13px; color: var(--tenue); }
.estado[data-state="on"] { color: var(--verde); }
.estado[data-state="connecting"] { color: var(--naranja); }
.estado[data-state="err"] { color: #f87171; }
#contenido { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.vista h1 { font-size: 20px; margin: 4px 0 12px; }
.nota { color: var(--tenue); font-size: 14px; }
.error { color: #f87171; font-size: 14px; }
label { display: block; margin: 18px 0 6px; font-size: 14px; color: var(--tenue); }
input[type="text"], input:not([type]), textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--linea);
  background: var(--panel); color: var(--texto); font: inherit;
}
button { font: inherit; cursor: pointer; }
.principal {
  margin-top: 14px; width: 100%; padding: 11px 14px; border: 0; border-radius: 10px;
  background: var(--acento); color: #fff; font-weight: 600;
}
.principal:disabled { opacity: 0.5; }
.volver {
  border: 0; background: none; color: var(--acento); padding: 0 0 6px; font-size: 15px;
}
#sesiones { list-style: none; margin: 0; padding: 0; }
#sesiones li {
  border: 1px solid var(--linea); border-radius: 12px; background: var(--panel);
  margin-bottom: 8px;
}
#sesiones li button {
  width: 100%; text-align: left; background: none; border: 0; color: inherit;
  padding: 12px 14px; display: flex; align-items: center; gap: 10px;
}
.punto { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.punto[data-s="trabajando"] { background: var(--verde); }
.punto[data-s="fallo"] { background: var(--naranja); }
.punto[data-s="terminada"] { background: var(--azul); }
.punto[data-s="espera-aprobacion"] { background: var(--azul); box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.25); }
.titulo-sesion { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proyecto { font-size: 12px; color: var(--tenue); }
#mensajes { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.mensaje { max-width: 92%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.mensaje[data-rol="user"] { align-self: flex-end; background: #1e3a8a; }
.mensaje[data-rol="assistant"] { align-self: flex-start; background: var(--panel); border: 1px solid var(--linea); }
.redactar {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--linea); background: var(--panel);
}
.redactar textarea { flex: 1; resize: none; max-height: 120px; }
.redactar .principal { width: auto; margin: 0; align-self: flex-end; }
.aviso { color: var(--tenue); font-size: 13px; text-align: center; padding: 6px 0; }

/* ---- F30: avisos genéricos, tarjetas de aprobación y nueva sesión ---- */
#avisos { display: flex; flex-direction: column; gap: 6px; }
.notificacion {
  margin: 0 0 6px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--linea);
}
.notificacion[data-kind="awaiting"] { border-color: var(--azul); }
.notificacion[data-kind="failed"] { border-color: var(--naranja); }
#aprobaciones { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.aprobacion {
  padding: 12px 14px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--azul);
}
.aprobacion-titulo { margin: 0 0 8px; font-weight: 600; font-size: 15px; }
.aprobacion-campo { margin: 0 0 6px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.aprobacion-campo span:first-child { color: var(--tenue); }
.aprobacion-campo span, .aprobacion-campo pre {
  margin: 0; white-space: pre-wrap; word-break: break-all; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.aprobacion-botones { display: flex; gap: 8px; margin-top: 10px; }
.aprobacion-botones .principal { margin-top: 0; flex: 1; }
.aprobacion-botones .ok { background: var(--verde); }
.aprobacion-botones .peligro { background: #b91c1c; }
.lista-acciones { display: flex; align-items: center; gap: 8px; }
.lista-acciones h1 { flex: 1; }
.secundario {
  padding: 7px 10px; border-radius: 9px; border: 1px solid var(--linea);
  background: var(--panel); color: var(--texto); font-size: 13px;
}
.elegir-proyecto {
  margin: 0 0 10px; padding: 10px; border-radius: 12px; border: 1px dashed var(--linea);
  display: flex; flex-direction: column; gap: 6px;
}
.proyecto-elegir {
  text-align: left; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--linea);
  background: var(--panel); color: inherit; font-size: 14px;
}
