* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: #0f172a; color: #e2e8f0; line-height: 1.5;
}
header {
  padding: 2rem; background: #1e293b; border-bottom: 1px solid #334155;
}
header h1 { font-size: 1.5rem; }
header .sub { color: #94a3b8; font-size: .9rem; margin-top: .25rem; }
#session { margin-top: .75rem; font-size: .9rem; color: #cbd5e1; }
#session a { color: #38bdf8; }
main { max-width: 900px; margin: 0 auto; padding: 2rem; }
main h2 { margin: 1.5rem 0 .75rem; font-size: 1.15rem; }
.hint, .warn, .sub { font-size: .85rem; }
.hint { color: #94a3b8; margin-bottom: 1rem; }
.warn { color: #fbbf24; margin-bottom: .75rem; }

button.primary {
  background: #38bdf8; color: #0f172a; border: 0; border-radius: 8px;
  padding: .7rem 1.4rem; font-size: 1rem; font-weight: 600; cursor: pointer;
  min-width: 140px; min-height: 44px;
}
button.primary:hover { background: #0ea5e9; }
button.primary:disabled { background: #475569; color: #94a3b8; cursor: not-allowed; }

/* Fila de controles WS: boton + estado / input + boton. */
.ws-row {
  display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem;
  flex-wrap: wrap;
}
#msg-input {
  flex: 1; min-width: 220px; padding: .7rem 1rem; font-size: 1rem;
  background: #0b1120; color: #e2e8f0; border: 1px solid #334155; border-radius: 8px;
}
#msg-input:focus { outline: none; border-color: #38bdf8; }

.badge { font-size: .8rem; padding: .35rem .7rem; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: #14532d; color: #86efac; }
.badge-no { background: #334155; color: #cbd5e1; }

pre#ws-log, pre#jwt-claims, pre#user-log {
  background: #0b1120; border: 1px solid #334155; border-radius: 8px;
  padding: 1rem; overflow-x: auto; font-size: .82rem; color: #a5b4fc;
  min-height: 3rem; max-height: 260px; overflow-y: auto; white-space: pre-wrap;
}
pre#ws-log, pre#user-log { color: #bbf7d0; }

/* Vista admin: bandeja de preguntas entrantes. */
.inbox { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.inbox-item {
  background: #1e293b; border: 1px solid #334155; border-left: 4px solid #64748b;
  border-radius: 8px; padding: .8rem 1rem; cursor: pointer;
}
.inbox-item:hover { border-color: #38bdf8; }
.inbox-item.sel { border-left-color: #22c55e; background: #16233b; }
.inbox-q { font-size: .95rem; color: #e2e8f0; }
.inbox-meta { font-size: .78rem; color: #94a3b8; margin-top: .3rem; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  padding: .8rem 1.4rem; border-radius: 8px; font-weight: 600; font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.toast.ok  { background: #14532d; color: #86efac; }
.toast.err { background: #7f1d1d; color: #fca5a5; }

/* Spinner + loader inicial (evita el parpadeo sin-sesion -> sesion). */
.spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 3px solid rgba(56,189,248,.25); border-top-color: #38bdf8;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#app-loader {
  position: fixed; inset: 0; z-index: 10000;
  background: #0f172a; display: flex; align-items: center; justify-content: center;
}
body.ready #app-loader { display: none; }
body:not(.ready) main, body:not(.ready) header { visibility: hidden; }
