:root {
  --bg: #0f172a;
  --card: #1e293b;
  --muted: #94a3b8;
  --text: #e2e8f0;
  --accent: #6366f1;
  --slack: #4a154b;
  --gmail: #c5221f;
  --ok: #22c55e;
  --err: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #233047;
}

header h1 { font-size: 20px; margin: 0; }

.actions { display: flex; gap: 8px; }

button {
  font-size: 15px;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  background: #334155;
  color: var(--text);
  cursor: pointer;
}

button.primary { background: var(--accent); color: #fff; }
button.full { width: 100%; padding: 13px; font-size: 16px; margin-top: 10px; }

.status { padding: 8px 16px; color: var(--muted); font-size: 13px; min-height: 18px; }

.feed { list-style: none; margin: 0; padding: 0 12px; }

.feed li {
  background: var(--card);
  border-radius: 12px;
  padding: 13px 14px;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feed .row { display: flex; align-items: center; gap: 8px; }

.badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
}
.badge.Slack { background: var(--slack); }
.badge.Gmail { background: var(--gmail); }

.feed .title { font-weight: 600; }
.feed .body { color: var(--muted); font-size: 14px; }
.feed .time { color: #64748b; font-size: 12px; margin-left: auto; }

.empty { text-align: center; color: var(--muted); margin-top: 40px; }
.hidden { display: none !important; }

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.sheet-card {
  background: var(--card);
  width: 100%;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
}

.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-card h2 { margin: 10px 0 6px; font-size: 18px; }
.sheet-card p { color: var(--muted); margin: 0 0 12px; }

textarea, input {
  width: 100%;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 10px;
  color: var(--text);
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
}

.reply-status { margin-top: 8px; font-size: 14px; min-height: 18px; }
.reply-status.ok { color: var(--ok); }
.reply-status.err { color: var(--err); }

/* --- Tabs --- */
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; color: var(--muted); padding: 6px 10px; font-size: 16px; font-weight: 600;
  border-bottom: 2px solid transparent; border-radius: 0;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.dot.on { background: var(--ok); }

.view { display: block; }

/* --- Slack: lista de conversaciones --- */
.slack-list { padding: 0 12px; }
#conv-filter { margin: 8px 0; }
.conversations { list-style: none; margin: 0; padding: 0; }
.conversations li {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px; border-bottom: 1px solid #1e293b; cursor: pointer;
}
.conversations li:active { background: #18233a; }
.conv-icon { width: 22px; text-align: center; color: var(--muted); }
.conv-name { font-size: 15px; }

/* --- Slack: hilo --- */
.slack-thread { display: flex; flex-direction: column; height: calc(100vh - 64px); }
.thread-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid #233047; position: sticky; top: 0; background: var(--bg);
}
.thread-head #thread-back { font-size: 22px; padding: 2px 10px; background: transparent; }
#thread-title { font-weight: 600; }

.messages { flex: 1; overflow-y: auto; padding: 10px 12px; }
.loading { color: var(--muted); text-align: center; padding: 20px; }
.msg { margin: 10px 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; font-size: 14px; }
.msg-time { color: #64748b; font-size: 11px; }
.msg-text { font-size: 15px; line-height: 1.4; white-space: normal; word-break: break-word; }
.msg-text a { color: #93c5fd; }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-img { max-width: 220px; max-height: 220px; border-radius: 10px; }
.msg-thread { color: #93c5fd; font-size: 13px; margin-top: 4px; cursor: pointer; }

.composer {
  display: flex; gap: 8px; padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid #233047; background: var(--bg);
}
.composer textarea { flex: 1; resize: none; max-height: 120px; }
.composer .primary { padding: 0 16px; }
#send-status { padding: 0 12px; }
