/* ═══════════════════════════════════════════════════════
   COMETA v3 · hoja de estilos
   Paleta: índigo profundo + ámbar (cometa) + azul hielo (Slack)
   Tipos:  Bricolage Grotesque (marca) · Instrument Sans (UI)
   ═══════════════════════════════════════════════════════ */
:root {
  --bg:        #15122b;
  --bg-deep:   #100e22;
  --panel:     #1e1a3a;
  --panel-2:   #272148;
  --line:      #352e5e;
  --text:      #f1edfc;
  --text-dim:  #a99fd1;
  --amber:     #ffb454;
  --amber-soft:#ffb45426;
  --ice:       #a8d8ff;
  --ice-soft:  #a8d8ff1f;
  --danger:    #ff7a8a;
  --ok:        #6fe3a1;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --font-ui: "Instrument Sans", system-ui, sans-serif;
  --font-brand: "Bricolage Grotesque", var(--font-ui);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
::selection { background: var(--amber); color: #2a1a00; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

/* ─────────── Acceso ─────────── */
.auth { min-height: 100dvh; display: grid; place-items: center; position: relative; overflow: hidden; padding: 24px 16px; }
.auth-sky { position: absolute; inset: 0; pointer-events: none; }
.comet-trail {
  position: absolute; top: -12%; right: -22%;
  width: 135%; height: 46%;
  transform: rotate(-16deg);
  background: linear-gradient(90deg, transparent 0%, #a8d8ff12 30%, #a8d8ff33 62%, #ffb45488 88%, #ffd08c 100%);
  filter: blur(26px); border-radius: 999px;
}
.comet-head {
  position: absolute; top: 9.5%; right: 6%;
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #fff6e3, var(--amber) 55%, transparent 75%);
  box-shadow: 0 0 60px 22px #ffb45466, 0 0 140px 60px #ffb45422;
}
.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 68%, #cfc4ff99 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 28% 22%, #cfc4ff77 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 47% 81%, #a8d8ff88 50%, transparent 51%),
    radial-gradient(1.1px 1.1px at 63% 34%, #cfc4ff66 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 81% 72%, #cfc4ff88 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 91% 18%, #a8d8ff77 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 6% 12%, #cfc4ff66 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 72% 9%, #cfc4ff55 50%, transparent 51%);
}
.auth-card {
  position: relative; width: min(380px, 100%);
  background: #1e1a3ad9; border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 34px 30px 26px;
  backdrop-filter: blur(10px);
}
.brand { font-family: var(--font-brand); font-weight: 800; font-size: 1.05rem; color: var(--amber); margin: 0 0 14px; }
.auth-card h1 { font-family: var(--font-brand); font-weight: 700; font-size: 1.7rem; line-height: 1.15; margin: 0 0 6px; }
.auth-sub { color: var(--text-dim); margin: 0 0 22px; }
.auth-card label { display: block; margin-bottom: 14px; }
.auth-card label span, .dlg label span {
  display: block; font-size: .86rem; font-weight: 600; color: var(--text-dim); margin-bottom: 5px;
}
.auth-card input, .dlg input, .dlg select {
  width: 100%; padding: 11px 13px;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg); color: var(--text); outline: none;
}
.auth-card input:focus, .dlg input:focus, .dlg select:focus, textarea:focus { border-color: var(--amber); }
.form-error { color: var(--danger); font-size: .88rem; min-height: 1.2em; margin: 2px 0 10px; }

.btn-primary {
  width: 100%; padding: 12px 18px; border: none;
  border-radius: var(--r-sm); background: var(--amber);
  color: #2a1a00; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { padding: 11px 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-wide { width: 100%; }
.link { display: block; margin: 16px auto 0; background: none; border: none; color: var(--ice); text-decoration: underline; text-underline-offset: 3px; }
.link-dim { color: var(--text-dim); margin: 0; display: inline; font-size: .85rem; }

/* ─────────── Estructura ─────────── */
.app { height: 100dvh; display: flex; }
.left { display: flex; flex: none; }

/* ─── Barra de organizaciones ─── */
.org-rail {
  width: 68px; flex: none;
  background: var(--bg-deep);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0 14px; gap: 10px;
  border-right: 1px solid #0a081d;
}
.org-brand {
  font-size: 1.3rem; width: 42px; height: 42px;
  display: grid; place-items: center;
  color: var(--amber);
  filter: drop-shadow(0 0 10px #ffb45455);
  margin-bottom: 2px;
}
.org-rail ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; overflow-y: auto; width: 100%; align-items: center; }
.org-btn {
  width: 44px; height: 44px; flex: none;
  border: none; padding: 0;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-brand); font-weight: 700; font-size: 1.05rem;
  display: grid; place-items: center;
  overflow: hidden;
  position: relative;
  transition: border-radius .15s ease;
}
.org-btn img { width: 100%; height: 100%; object-fit: cover; }
.org-btn:hover { border-radius: 10px; }
.org-btn.active { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 10px; }
.org-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px; background: var(--amber); color: #2a1a00;
  font-size: .68rem; font-weight: 700; font-family: var(--font-ui);
  display: grid; place-items: center;
  border: 2px solid var(--bg-deep);
}
.org-add {
  width: 44px; height: 44px; flex: none;
  border: 1px dashed var(--line); border-radius: 14px;
  background: none; color: var(--text-dim); font-size: 1.3rem;
}
.org-add:hover { color: var(--amber); border-color: var(--amber); }

/* ─── Barra de canales ─── */
.rail {
  width: 250px; flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0;
}
.rail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 15px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: radial-gradient(130px 42px at 94% 0%, #ffb45414, transparent 70%), var(--panel);
}
.org-title {
  font-family: var(--font-brand); font-weight: 700; font-size: 1.08rem;
  margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-scroll { flex: 1; overflow-y: auto; padding: 12px 8px 16px; }
.rail-group { margin-bottom: 20px; }
.rail-group-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 4px; }
.rail-group-head h2 { font-size: .82rem; font-weight: 600; color: var(--text-dim); margin: 0; }
.rail-group ul { list-style: none; margin: 0; padding: 0; }
.rail-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border: none; background: none;
  border-radius: var(--r-sm); color: var(--text-dim);
  text-align: left; min-width: 0;
}
.rail-item:hover { background: var(--panel-2); color: var(--text); }
.rail-item.active { background: var(--amber-soft); color: var(--text); }
.rail-item.has-unread { color: var(--text); font-weight: 600; }
.rail-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-pill {
  min-width: 20px; padding: 1px 6px;
  border-radius: 99px; background: var(--amber); color: #2a1a00;
  font-size: .72rem; font-weight: 700; text-align: center;
}
.hash { opacity: .6; }
.bridge-mark { color: var(--ice); font-size: .8rem; }
.ia-dot { color: var(--amber); }
.audit-ico { color: var(--amber); }
#group-admin .rail-item.active { background: var(--amber-soft); }
.rail-group-slack .rail-item.active { background: var(--ice-soft); }
.slack-ws-btn {
  width: 100%; display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border: none; background: none;
  border-radius: var(--r-sm);
  color: var(--ice); font-weight: 600; text-align: left;
}
.slack-ws-btn:hover { background: var(--ice-soft); }
.slack-ws-btn .chev { font-size: .75rem; width: 12px; flex: none; opacity: .8; }
.slack-ws-btn .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-count { font-size: .72rem; color: var(--text-dim); font-weight: 400; }
.slack-sub {
  margin: 6px 0 2px; padding: 0 10px 0 28px;
  font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  color: var(--text-dim);
}
.slack-convo { padding-left: 28px; }
.mini-ava {
  width: 20px; height: 20px; flex: none;
  border-radius: 6px; object-fit: cover;
  display: grid; place-items: center;
}
.mini-ava-ph {
  background: var(--ice);
  color: #15122b; font-size: .6rem; font-weight: 700;
  border-radius: 50%;
}
.avatar-img { object-fit: cover; padding: 0; border: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px #6fe3a177; }
.dot-me { background: var(--ok); }
.rail-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.me-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { border: none; background: none; color: var(--text-dim); font-size: 1rem; padding: 4px 8px; border-radius: var(--r-sm); line-height: 1; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ─── Sala ─── */
.room { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.room-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.room-title { flex: 1; min-width: 0; }
.room-title h1 { font-family: var(--font-brand); font-weight: 700; font-size: 1.15rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-title p { margin: 0; font-size: .84rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* barra de búsqueda superior (estilo Slack) */
.topbar-search {
  flex: 0 1 380px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  min-width: 140px;
}
.topbar-search:focus-within { border-color: var(--amber); }
.ts-ico { font-size: .85rem; opacity: .7; }
.topbar-search input {
  flex: 1; min-width: 0;
  border: none; background: none; outline: none;
  color: var(--text); font-size: .9rem;
}
.topbar-search input::placeholder { color: var(--text-dim); }

/* chips de ámbito de búsqueda */
.scope-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: -8px; margin-bottom: 16px; }
.scope-lbl { font-size: .82rem; color: var(--text-dim); }
.chip {
  padding: 5px 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--text-dim);
  font-size: .84rem;
}
.chip:hover { border-color: var(--amber); color: var(--text); }
.chip.sel { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); font-weight: 600; }
.badge { font-size: .76rem; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--ice); color: var(--ice); white-space: nowrap; background: none; }
.badge-refresh { border-color: var(--line); color: var(--text-dim); }
.badge-refresh:hover { color: var(--text); }

.feed { flex: 1; overflow-y: auto; padding: 18px 20px 6px; display: flex; flex-direction: column; gap: 2px; }
.day-sep {
  align-self: center; font-size: .78rem; color: var(--text-dim);
  background: var(--panel); border: 1px solid var(--line);
  padding: 2px 12px; border-radius: 999px; margin: 14px 0 8px;
}
.msg { display: flex; gap: 11px; padding: 5px 8px; border-radius: var(--r-sm); position: relative; }
.msg:hover { background: #ffffff06; }
.msg.compact { padding-top: 1px; }
.avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem; color: #15122b;
}
.avatar.slack { background: var(--ice); border-radius: 50%; }
.avatar.ia { background: linear-gradient(135deg, var(--amber), #ff8a5c); border-radius: 50%; color: #2a1a00; }
.msg.compact .avatar { visibility: hidden; height: 0; }
.msg-main { min-width: 0; flex: 1; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; }
.msg-time { font-size: .76rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.msg-edited { font-size: .72rem; color: var(--text-dim); font-style: italic; }
.msg-slack-tag { font-size: .72rem; color: var(--ice); border: 1px solid var(--ice-soft); background: var(--ice-soft); padding: 0 6px; border-radius: 999px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.feed-empty { margin: auto; text-align: center; color: var(--text-dim); max-width: 340px; }
.feed-empty strong { color: var(--text); font-family: var(--font-brand); }

/* adjuntos dentro del mensaje */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-img {
  max-width: min(340px, 100%); max-height: 260px;
  border-radius: var(--r-md); border: 1px solid var(--line);
  cursor: zoom-in; display: block; object-fit: cover;
}
.att-file {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--panel);
  color: var(--ice); text-decoration: none; font-size: .9rem; max-width: 100%;
}
.att-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file:hover { border-color: var(--ice); }

/* acciones al pasar el ratón */
.msg-actions {
  position: absolute; top: -14px; right: 10px;
  display: none; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 3px 6px;
  box-shadow: 0 6px 18px #00000055;
}
.msg:hover .msg-actions { display: flex; }
.msg-actions button { border: none; background: none; font-size: .95rem; padding: 2px 5px; border-radius: 6px; line-height: 1; }
.msg-actions button:hover { background: var(--panel); }
.emoji-pop {
  position: absolute; top: -52px; right: 10px; z-index: 5;
  display: flex; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 6px 8px;
  box-shadow: 0 10px 28px #00000077;
}
.emoji-pop button { border: none; background: none; font-size: 1.15rem; padding: 3px 5px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--panel); transform: scale(1.12); }

/* reacciones */
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.reaction {
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 1px 9px;
  font-size: .85rem; display: inline-flex; gap: 5px; align-items: center;
}
.reaction .n { font-size: .76rem; color: var(--text-dim); font-weight: 600; }
.reaction:hover { border-color: var(--amber); }
.reaction.mine { background: var(--amber-soft); border-color: var(--amber); }
.reaction.mine .n { color: var(--amber); }

.typing { min-height: 20px; margin: 0; padding: 0 24px; font-size: .8rem; color: var(--text-dim); font-style: italic; }

/* página de auditoría */
.audit-page { max-width: 760px; margin: 0 auto; width: 100%; padding: 8px 4px 24px; }
.audit-head h2 { font-family: var(--font-brand); font-weight: 700; font-size: 1.4rem; margin: 6px 0 4px; }
.audit-head p { color: var(--text-dim); font-size: .9rem; margin: 0 0 14px; }
.audit-search {
  width: 100%; padding: 10px 14px; margin-bottom: 20px;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--panel); color: var(--text); outline: none;
}
.audit-search:focus { border-color: var(--amber); }
.audit-section { margin-bottom: 22px; }
.audit-section h3 {
  font-size: .82rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px;
}
.audit-section ul { list-style: none; margin: 0; padding: 0; }
.audit-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 4px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel); color: var(--text); text-align: left;
}
.audit-item:hover { border-color: var(--amber); background: var(--panel-2); }
.audit-ava {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px; background: var(--panel-2);
  color: var(--text-dim); font-weight: 700;
}
.audit-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-when { font-size: .78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.audit-empty { color: var(--text-dim); font-size: .88rem; padding: 6px 4px; }

/* filtro de búsqueda de auditoría */
.audit-filter {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel); padding: 16px; margin-bottom: 22px;
}
.audit-filter h3 { margin: 0 0 12px; font-size: .9rem; }
.af-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.af-date { display: flex; flex-direction: column; font-size: .78rem; color: var(--text-dim); gap: 4px; }
.af-date input {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); color: var(--text); outline: none; color-scheme: dark;
}
.af-date input:focus { border-color: var(--amber); }
.af-go { width: auto; }
.af-clear { padding: 10px 16px; }
.audit-filter .dlg-help { margin: 12px 0 0; }

/* página de roles */
.role-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 4px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel);
  flex-wrap: wrap;
}
.role-who { flex: 1; min-width: 140px; display: flex; flex-direction: column; line-height: 1.25; }
.role-who em { font-style: normal; color: var(--text-dim); font-size: .8rem; }
.role-tag {
  font-size: .76rem; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-dim); white-space: nowrap;
}
.role-tag.role-admin { border-color: var(--ice); color: var(--ice); }
.role-tag.role-global { border-color: var(--amber); color: var(--amber); }
.role-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-sm { padding: 6px 12px; font-size: .84rem; }

/* resultados de búsqueda */
.search-hit {
  width: 100%; display: flex; flex-direction: column; gap: 4px;
  padding: 11px 14px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel); color: var(--text); text-align: left;
}
.search-hit:hover { border-color: var(--amber); background: var(--panel-2); }
.sh-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sh-top strong { color: var(--ice); font-weight: 600; }
.sh-top em { font-style: normal; color: var(--text-dim); font-size: .85rem; }
.sh-top .audit-when { margin-left: auto; }
.sh-body { font-size: .92rem; color: var(--text); overflow-wrap: anywhere; }
mark { background: var(--amber); color: #2a1a00; border-radius: 4px; padding: 0 2px; }

/* mensaje resaltado al saltar desde la búsqueda */
.msg.highlight { background: var(--amber-soft); outline: 1px solid var(--amber); transition: background .6s ease, outline-color .6s ease; }

/* ─── botones de llamada en la cabecera del DM ─── */
.call-head-btn {
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 999px;
  padding: 5px 12px; font-size: .9rem;
}
.call-head-btn:hover { border-color: var(--ok); color: var(--ok); }

/* ─── llamada entrante ─── */
.incoming {
  position: fixed; inset: 0; z-index: 80;
  background: #0a081dcc; backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.incoming-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 32px 40px; text-align: center;
  box-shadow: 0 24px 80px #000;
}
.incoming-ava {
  width: 84px; height: 84px; margin: 0 auto 16px;
  border-radius: 50%; display: grid; place-items: center;
  font-size: 2rem; font-weight: 700; color: #15122b;
  background: var(--amber);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 #ffb45466; } 50% { box-shadow: 0 0 0 18px #ffb45400; } }
.incoming-name { font-family: var(--font-brand); font-weight: 700; font-size: 1.3rem; margin: 0 0 2px; }
.incoming-kind { color: var(--text-dim); margin: 0 0 24px; }
.incoming-actions { display: flex; gap: 40px; justify-content: center; }

.call-btn {
  width: 56px; height: 56px; border: none; border-radius: 50%;
  font-size: 1.4rem; display: grid; place-items: center;
  background: var(--panel-2); color: var(--text); cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.call-btn:hover { transform: scale(1.08); }
.call-btn.active { background: var(--amber); color: #2a1a00; }
.call-btn.off { background: var(--danger); color: #fff; }
.call-accept { background: var(--ok); color: #0c2a18; }
.call-reject, .call-hangup { background: var(--danger); color: #fff; }
.call-hangup { transform: rotate(135deg); }
.call-hangup:hover { transform: rotate(135deg) scale(1.08); }

/* ─── ventana de llamada ─── */
.call-ui {
  position: fixed; inset: 0; z-index: 75;
  background: #0b0a1a;
  display: flex; flex-direction: column;
}
.call-stage { flex: 1; position: relative; overflow: hidden; display: grid; place-items: center; }
.remote-video { width: 100%; height: 100%; object-fit: contain; background: #0b0a1a; }
.remote-video.hidden-vid { display: none; }
.call-remote-info { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; }
.call-remote-info.hidden { display: none; }
.call-big-ava {
  width: 120px; height: 120px; border-radius: 50%;
  display: grid; place-items: center; font-size: 3rem; font-weight: 700;
  color: #15122b; background: var(--amber);
}
#call-peer-name { font-family: var(--font-brand); font-weight: 700; font-size: 1.5rem; margin: 0; color: var(--text); }
.call-status { color: var(--text-dim); margin: 0; }
.local-video {
  position: absolute; bottom: 18px; right: 18px;
  width: 200px; max-width: 34vw; aspect-ratio: 16/10;
  object-fit: cover; border-radius: var(--r-md);
  border: 1px solid var(--line); background: #000;
  box-shadow: 0 10px 30px #00000088; transform: scaleX(-1);
}
.local-video.hidden-vid { display: none; }
.call-bar {
  display: flex; gap: 18px; justify-content: center;
  padding: 18px calc(16px + env(safe-area-inset-bottom));
  background: #100e22; border-top: 1px solid var(--line);
}
@media (max-width: 760px) {
  .local-video { width: 120px; bottom: 12px; right: 12px; }
  .call-bar { gap: 12px; }
  .call-btn { width: 50px; height: 50px; font-size: 1.25rem; }
}

/* menciones */
.mention {
  color: var(--ice);
  background: var(--ice-soft);
  border-radius: 6px;
  padding: 0 4px;
  font-weight: 600;
}
.mention.me {
  color: #2a1a00;
  background: var(--amber);
}
.mention-pop {
  position: absolute;
  bottom: calc(100% + 6px); left: 68px;
  min-width: 240px; max-width: 320px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 14px 40px #00000088;
  padding: 5px;
  z-index: 20;
  display: flex; flex-direction: column;
}
.composer { position: relative; }
.mention-pop button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; border: none; background: none;
  padding: 7px 9px; border-radius: var(--r-sm); text-align: left;
}
.mention-pop button:hover, .mention-pop button.sel { background: var(--amber-soft); }
.mp-ava {
  width: 26px; height: 26px; flex: none;
  border-radius: 8px; background: var(--panel);
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 700;
}
.mp-ava.slack { background: var(--ice); color: #15122b; border-radius: 50%; }
.mp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-sub { font-size: .76rem; color: var(--text-dim); }

/* adjuntos pendientes de enviar */
.pending { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px; }
.pending:not(:empty) { padding-bottom: 6px; }
.pend-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); padding: 5px 9px; font-size: .85rem; color: var(--text-dim);
}
.pend-chip img { width: 30px; height: 30px; object-fit: cover; border-radius: 6px; }
.pend-chip button { border: none; background: none; color: var(--danger); font-size: .95rem; padding: 0 2px; }

.composer { display: flex; gap: 10px; align-items: flex-end; padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); }
.composer textarea {
  flex: 1; resize: none; max-height: 160px;
  padding: 11px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); outline: none;
}
.btn-send {
  width: 42px; height: 42px; flex: none; border: none; border-radius: 50%;
  background: var(--amber); color: #2a1a00; font-size: 1.15rem; font-weight: 700;
}
.btn-send:disabled { background: var(--line); color: var(--text-dim); cursor: default; }
.btn-attach {
  width: 42px; height: 42px; flex: none;
  border: 1px solid var(--line); border-radius: 50%;
  background: none; color: var(--text-dim); font-size: 1.2rem; line-height: 1;
}
.btn-attach:hover { color: var(--amber); border-color: var(--amber); }
.room.dragover .feed { outline: 2px dashed var(--amber); outline-offset: -10px; border-radius: var(--r-lg); }

/* visor de imágenes */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: #0a081de6; backdrop-filter: blur(4px);
  display: grid; place-items: center; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: var(--r-md); box-shadow: 0 20px 80px #000; }

/* ─── Diálogos ─── */
dialog {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--panel); color: var(--text);
  padding: 0; width: min(430px, calc(100vw - 32px));
}
dialog::backdrop { background: #0a081dcc; backdrop-filter: blur(3px); }
.dlg { padding: 24px; }
dialog.wide { width: min(580px, calc(100vw - 32px)); }
.dlg h2 { font-family: var(--font-brand); font-weight: 700; margin: 0 0 14px; font-size: 1.25rem; }
.dlg h3 { font-size: .95rem; margin: 0 0 6px; }
.dlg label { display: block; margin-bottom: 12px; }
.dlg-help { color: var(--text-dim); font-size: .88rem; margin: 0 0 14px; }
.dlg-help code { color: var(--ice); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.dlg-actions .btn-primary { width: auto; }
.org-sep { text-align: center; color: var(--text-dim); margin: 14px 0; font-size: .85rem; }
.btn-slack {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 18px;
  border: none; border-radius: var(--r-sm);
  background: var(--ice); color: #0d2238;
  font-weight: 700; font-size: 1rem;
  margin-bottom: 4px;
}
.btn-slack:hover { filter: brightness(1.06); }
.slack-logo { font-weight: 800; letter-spacing: -2px; transform: rotate(45deg); display: inline-block; }
#form-org-create .btn-primary { margin-top: 2px; }

.pick-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.pick-list button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: none; background: none;
  border-radius: var(--r-sm); text-align: left;
}
.pick-list button:hover { background: var(--panel-2); }

.set-block { margin-bottom: 20px; }
.invite-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.invite-row code {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 12px;
  letter-spacing: .12em; color: var(--amber); font-weight: 700;
}
.pass-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pass-row input { flex: 1; min-width: 150px; }
.org-admin-row { display: flex; gap: 8px; align-items: center; margin: 6px 0 10px; flex-wrap: wrap; }
.org-admin-row input { flex: 1; min-width: 150px; }
.org-logo-lbl {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px dashed var(--line); border-radius: var(--r-sm);
  padding: 8px 12px; cursor: pointer; color: var(--text-dim); font-size: .9rem;
  margin: 0;
}
.org-logo-lbl:hover { border-color: var(--amber); color: var(--amber); }
.org-logo-preview { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.bridge-list { list-style: none; margin: 0 0 12px; padding: 0; }
.bridge-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--r-sm); margin-bottom: 6px; font-size: .9rem;
}
.bridge-list .grow { flex: 1; }
.bridge-list .del { border: none; background: none; color: var(--danger); }
.bridge-form { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.bridge-form .btn-primary { grid-column: 1 / -1; width: auto; justify-self: end; }
.bridge-arrow { color: var(--ice); }

/* ─── Móvil ─── */
.only-mobile { display: none; }
@media (max-width: 760px) {
  .left {
    position: fixed; inset: 0 22% 0 0; z-index: 30;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 14px 0 40px #00000066;
  }
  .left.open { transform: none; }
  .rail { width: auto; flex: 1; }
  .only-mobile { display: inline-block; }
  .topbar-search { display: none; } /* en móvil se busca con el 🔍 de la barra lateral */
  .bridge-form { grid-template-columns: 1fr; }
  .bridge-arrow { display: none; }
  .att-img { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ─────────── Clientes: salas de video / reuniones ─────────── */
.clients-ico { color: var(--ice); }
.clients-page { max-width: 760px; margin: 0 auto; padding: 8px 4px 40px; }
.clients-head h2 { font-family: var(--font-brand); font-weight: 700; margin: 0 0 6px; }
.clients-head p { color: var(--text-dim); margin: 0 0 20px; line-height: 1.5; }
.clients-new { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.room-kind {
  padding: 11px 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--panel); color: var(--text); outline: none; cursor: pointer;
}
.room-kind:focus { border-color: var(--amber); }
.clients-note { color: var(--ice); font-size: .88rem; min-height: 1.2em; margin: 4px 2px 18px; }
.clients-list { display: grid; gap: 14px; }
.clients-empty { color: var(--text-dim); text-align: center; padding: 34px; border: 1px dashed var(--line); border-radius: var(--r-md); }
.room-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); padding: 16px; }
.room-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.room-kind-ico { font-size: 1.5rem; flex: none; }
.room-card-info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.room-card-info strong { font-weight: 600; }
.room-code { font-family: ui-monospace, monospace; letter-spacing: .08em; color: var(--amber); font-size: .82rem; }
.room-live-badge { color: #7df740; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.room-idle { color: var(--text-dim); font-size: .82rem; white-space: nowrap; }
.room-card-link input {
  width: 100%; padding: 9px 11px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg); color: var(--ice); font-size: .85rem; outline: none; margin-bottom: 12px;
}
.room-card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.room-card-actions .btn-primary, .room-card-actions .btn-ghost { padding: 9px 16px; font-size: .9rem; }
.room-card-actions .room-del { margin-left: auto; padding: 9px 12px; }

/* ─────────── Invitaciones por correo ─────────── */
.invite-banner {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--amber-soft); border: 1px solid var(--amber);
  border-radius: var(--r-md); padding: 12px 14px; margin: 0 0 18px;
}
.invite-banner.err { background: #ff7a8a1a; border-color: var(--danger); }
.invite-banner .ib-ico {
  font-size: 1.3rem; width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--amber); color: #2a1a00;
}
.invite-banner strong { display: block; font-weight: 700; }
.invite-banner span { display: block; font-size: .85rem; color: var(--text-dim); }

.invite-page { max-width: 720px; margin: 0 auto; padding: 8px 4px 40px; }
.invite-head h2 { font-family: var(--font-brand); font-weight: 700; margin: 0 0 6px; }
.invite-head p { color: var(--text-dim); margin: 0 0 20px; line-height: 1.5; }
.invite-new { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.invite-sub { font-size: .9rem; color: var(--text-dim); font-weight: 600; margin: 18px 0 10px; }
.invite-list { display: grid; gap: 10px; }
.invite-card {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); padding: 12px 14px;
}
.invite-card-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.invite-card-info strong { font-weight: 600; }
.invite-card-actions { display: flex; gap: 8px; flex: none; }
.invite-card-actions .btn-ghost { padding: 8px 12px; font-size: .88rem; }

/* ═══════════ Perfil: botón del pie + menú estilo Slack ═══════════ */
.rail-foot { display: block; padding: 8px; border-top: 1px solid var(--line); }
.me-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  background: transparent; border: none; border-radius: var(--r-sm); padding: 7px 8px; color: var(--text);
}
.me-btn:hover { background: var(--panel-2); }
.me-ava {
  width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #15122b; background: var(--amber);
}
.me-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-status { font-size: .76rem; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.me-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.me-caret { color: var(--text-dim); font-size: 1rem; }

.profile-menu {
  position: fixed; left: 70px; bottom: 60px; z-index: 60; width: 252px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px; box-shadow: 0 16px 48px #0009;
}
.pm-head { display: flex; align-items: center; gap: 11px; padding: 8px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.pm-ava { width: 42px; height: 42px; flex: none; border-radius: 11px; display: grid; place-items: center; font-weight: 700; color: #15122b; background: var(--amber); }
.pm-head-info { min-width: 0; display: flex; flex-direction: column; }
.pm-head-info strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-online { font-size: .78rem; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.pm-item {
  width: 100%; display: flex; align-items: center; gap: 11px; text-align: left;
  background: transparent; border: none; border-radius: var(--r-sm); padding: 9px 10px; color: var(--text); font-size: .92rem;
}
.pm-item:hover { background: var(--panel-2); }
.pm-ico { width: 20px; text-align: center; }
.pm-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.pm-danger { color: var(--danger); }
.pm-danger:hover { background: #ff7a8a1a; }

/* diálogo editar perfil */
.prof-preview { display: flex; align-items: center; gap: 13px; margin: 4px 0 20px; }
.prof-ava { width: 54px; height: 54px; flex: none; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; color: #15122b; background: var(--amber); }
.prof-preview strong { display: block; font-weight: 700; }
.prof-field { display: block; margin-bottom: 14px; }
.prof-field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.prof-field input { width: 100%; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none; }
.prof-field input:focus { border-color: var(--amber); }
.color-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.color-dot { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-dot.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }

/* ═══════════ Tema claro ═══════════ */
:root[data-theme="light"] {
  --bg:        #f5f3fb;
  --bg-deep:   #ebe8f6;
  --panel:     #ffffff;
  --panel-2:   #f1eefa;
  --line:      #e4e0f0;
  --text:      #211d3a;
  --text-dim:  #6f6a93;
  --amber:     #e89420;
  --amber-soft:#e8942018;
  --ice:       #2f7fd1;
  --ice-soft:  #2f7fd114;
  --danger:    #e0556a;
  --ok:        #27a96a;
}
:root[data-theme="light"] body { background: var(--bg); }
:root[data-theme="light"] .org-rail { background: #efecf8; }
:root[data-theme="light"] .me-ava,
:root[data-theme="light"] .pm-ava,
:root[data-theme="light"] .prof-ava { color: #fff; }
:root[data-theme="light"] .btn-primary,
:root[data-theme="light"] .btn-send { color: #fff; }
:root[data-theme="light"] ::selection { background: var(--amber); color: #fff; }
:root[data-theme="light"] .color-dot.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--text); }

/* ═══════════ Juntas, llamadas y perfil de persona ═══════════ */
.meet-btn { width: auto !important; border-radius: 999px !important; padding: 6px 14px !important; font-size: .85rem !important; font-weight: 600; background: var(--amber-soft) !important; border: 1px solid var(--amber) !important; color: var(--amber) !important; }
.meet-btn:hover { background: var(--amber) !important; color: #2a1a00 !important; }
.avatar-link { cursor: pointer; transition: transform .1s ease; }
.avatar-link:hover { transform: scale(1.06); outline: 2px solid var(--amber); outline-offset: 1px; }
.join-meet {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
  background: var(--amber); color: #2a1a00; font-weight: 700; text-decoration: none;
  padding: 7px 14px; border-radius: 999px; font-size: .9rem;
}
.join-meet:hover { filter: brightness(1.06); }

/* panel de perfil de una persona */
#dlg-person .dlg { min-width: 320px; }
.pv-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.pv-ava { width: 60px; height: 60px; flex: none; border-radius: 16px; display: grid; place-items: center; font-weight: 700; font-size: 1.4rem; color: #15122b; background: var(--amber); }
.pv-head-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pv-head-info strong { font-family: var(--font-brand); font-weight: 700; font-size: 1.15rem; }
.pv-username { color: var(--text-dim); font-size: .85rem; }
.pv-status { font-size: .85rem; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.pv-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pv-dot.on { background: var(--ok); } .pv-dot.off { background: var(--line); }
.pv-role-line { margin: 0 0 16px; }
.pv-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.pv-actions .btn-primary, .pv-actions .btn-ghost { padding: 10px 16px; font-size: .9rem; }
:root[data-theme="light"] .pv-ava { color: #fff; }

/* ═══════════ Roles ampliados + plantillas de organización ═══════════ */
.role-tag.role-ceo     { border-color: #ffd36e; color: #ffd36e; background: #ffd36e14; }
.role-tag.role-admin   { border-color: var(--ice); color: var(--ice); }
.role-tag.role-leader  { border-color: #7df7c0; color: #7df7c0; }
.role-tag.role-auditor { border-color: #c0a8ff; color: #c0a8ff; }
.role-tag.role-member  { border-color: var(--line); color: var(--text-dim); }
.roles-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.role-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); }
.role-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.role-who em { color: var(--text-dim); font-style: normal; font-size: .82rem; }
.role-controls { display: flex; align-items: center; gap: 8px; }
.role-select { padding: 7px 10px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; outline: none; }
.role-select:focus { border-color: var(--amber); }
.btn-sm { padding: 6px 11px !important; font-size: .82rem !important; }
.mp-sub { color: var(--text-dim); font-size: .85rem; }

.tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 6px 0 10px; }
.tpl-card { display: flex; align-items: center; gap: 9px; text-align: left; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); color: var(--text); }
.tpl-card:hover { border-color: var(--amber); }
.tpl-card.sel { border-color: var(--amber); background: var(--amber-soft); }
.tpl-ico { font-size: 1.25rem; flex: none; }
.tpl-name { font-weight: 600; font-size: .88rem; line-height: 1.2; }
.tpl-channels { color: var(--text-dim); font-size: .83rem; margin: 0 0 14px; }
.tpl-channels code { color: var(--ice); background: var(--ice-soft); padding: 1px 6px; border-radius: 6px; margin: 0 2px; }
@media (max-width: 520px) { .tpl-grid { grid-template-columns: 1fr; } }
