/* ═══════════════════════════════════════════════════════
   COMETA · hoja de estilos
   Paleta: índigo profundo + ámbar (cometa) + azul hielo (Slack)
   Tipos:  Bricolage Grotesque (marca) · Instrument Sans (UI)
   ═══════════════════════════════════════════════════════ */
:root {
  --bg:        #15122b;
  --panel:     #1e1a3a;
  --panel-2:   #272148;
  --line:      #352e5e;
  --text:      #f1edfc;
  --text-dim:  #a99fd1;
  --amber:     #ffb454;
  --amber-soft:#ffb45426;
  --ice:       #a8d8ff;
  --ice-soft:  #a8d8ff1f;
  --danger:    #ff7a8a;
  --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; }

/* ─────────── 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;
  letter-spacing: .01em;
  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;
}
.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 de la app ─────────── */
.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 268px 1fr;
}

/* ─── Barra lateral ─── */
.rail {
  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;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120px 40px at 92% 0%, #ffb45418, transparent 70%),
    var(--panel);
}
.brand-small { margin: 0; font-size: 1.15rem; }
.rail-scroll { flex: 1; overflow-y: auto; padding: 10px 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 .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hash { opacity: .6; }
.bridge-mark { color: var(--ice); font-size: .8rem; }

.rail-group-slack .rail-item.active { background: var(--ice-soft); }
.slack-ws { padding: 3px 10px 1px; font-size: .8rem; color: var(--ice); opacity: .85; }
.slack-convo { padding-left: 22px; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line); flex: none;
}
.dot.on { background: #6fe3a1; box-shadow: 0 0 8px #6fe3a177; }
.dot-me { background: #6fe3a1; }

.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; }
.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;
}
.badge {
  font-size: .76rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--ice);
  color: var(--ice);
  white-space: nowrap;
}
.badge-refresh { border-color: var(--line); color: var(--text-dim); background: none; }
.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 6px; border-radius: var(--r-sm); }
.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%; }
.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-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); }

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

.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 10px 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; }

/* ─── 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; }
.dlg-wide { width: 100%; }
dialog.wide { width: min(560px, 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; }

.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; }
.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) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 25% 0 0;
    z-index: 30;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 14px 0 40px #00000066;
  }
  .rail.open { transform: none; }
  .only-mobile { display: inline-block; }
  .bridge-form { grid-template-columns: 1fr; }
  .bridge-arrow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
