/* Chat da equipe (#/chat), no estilo mural: bloco azul do squad, mensagens numa superficie branca sem baloes e
   campo de mensagem fixo embaixo. Telas em public/chat.js. Mesmo mundo do app: azul Samsung em campo inteiro,
   ciano do logo so sobre azul, acao principal em pilula preta. */

/* ---------- estrutura ---------- */
main.ch-main { padding-bottom: var(--ch-space, 200px); gap: 14px; }
.ch-wrap { display: flex; flex-direction: column; gap: 14px; }
.ch-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ch-side { display: contents; }
.ch-older { align-self: center; }

/* Bloco do squad: no celular fica no topo da conversa; no desktop, na coluna lateral. */
.ch-team { order: -1; background: var(--blue); color: #FFFFFF; border-radius: var(--radius); padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.ch-team h1 { font-size: 28px; overflow-wrap: anywhere; }
.ch-team-sub { margin-top: 3px; font-size: 13px; color: rgba(255, 255, 255, 0.84); }
.ch-faces { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ch-face { position: relative; }
.ch-face img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.24); background: #FFFFFF; opacity: 0.5; transition: opacity 0.3s var(--ease), border-color 0.3s var(--ease); }
.ch-face.spoke img { opacity: 1; border-color: var(--logo-cyan); }
.ch-face .on { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #5FD38D; border: 2px solid var(--blue); }
.ch-team-pts { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; color: rgba(255, 255, 255, 0.88); }
.ch-team-pts b { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--logo-cyan); white-space: nowrap; }
.ch-members { display: none; }

/* ---------- mensagens ---------- */
.ch-feed { background: var(--surface); border-radius: var(--radius); padding: 4px 0 6px; }
.ch-start { padding: 22px 18px; color: var(--muted); text-align: center; font-size: 13px; text-wrap: pretty; }
.ch-start b { color: var(--blue); font-family: var(--mono); }
.ch-begin { padding: 14px 16px 6px; font-size: 12px; color: var(--muted); text-align: center; text-wrap: balance; }
.ch-begin + .ch-day { padding-top: 4px; }
.ch-day { display: flex; align-items: center; gap: 10px; padding: 12px 16px 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.ch-day::before, .ch-day::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.ch-post { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0 12px; padding: 12px 16px 8px; }
.ch-post + .ch-post { border-top: 1px solid var(--line); }
.ch-post.cont { border-top: 0; padding-top: 0; }
.ch-post.cont > .avatar { visibility: hidden; height: 0; }
.ch-post > .avatar { width: 40px; height: 40px; }
.ch-post.pending { opacity: 0.55; }
.ch-body { min-width: 0; }
.ch-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ch-line b { font-size: 15px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-line .you { font-size: 13px; color: var(--muted); flex: none; }
.ch-line time { flex: none; font: 400 12px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.ch-line .pts { margin-left: auto; font-size: 12px; }
.ch-text { font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-post.deleted .ch-text { color: var(--muted); }
.ch-quote { display: flex; gap: 6px; align-items: center; min-width: 0; margin: 2px 0 2px; font-size: 13px; color: var(--muted); }
.ch-quote svg { width: 14px; height: 14px; flex: none; }
.ch-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reacoes e acoes: sempre visiveis (no celular nao ha passar o mouse), discretas ate o toque. */
.ch-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.ch-react { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 2px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--text); font: 600 12px var(--mono); font-variant-numeric: tabular-nums; }
button.ch-react { cursor: pointer; transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease); }
button.ch-react:hover { border-color: var(--blue); }
.ch-react[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-tint); color: var(--blue); }
.ch-icon { display: inline-grid; place-items: center; width: 36px; height: 32px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; transition: background-color 0.2s var(--ease), color 0.2s var(--ease); }
.ch-icon svg { width: 18px; height: 18px; }
.ch-acts > .ch-icon:first-child { margin-left: -9px; }
.ch-icon:hover, .ch-icon[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.ch-picker { display: flex; gap: 2px; width: max-content; max-width: 100%; margin-top: 6px; padding: 4px; border-radius: 999px; background: var(--surface-2); animation: ch-pop 0.22s var(--ease); }
.ch-picker button { width: 44px; height: 40px; border: 0; border-radius: 999px; background: none; font-size: 19px; line-height: 1; cursor: pointer; transition: background-color 0.15s var(--ease), transform 0.15s var(--ease); }
.ch-picker button:hover { background: var(--surface); }
.ch-picker button:active { transform: scale(0.92); }
.ch-picker button[aria-pressed="true"] { background: var(--blue-tint); box-shadow: inset 0 0 0 1px var(--blue); }
@keyframes ch-pop { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- campo de mensagem ---------- */
.ch-composer { position: fixed; z-index: 19; left: var(--ch-left, 0px); width: var(--ch-width, 100%); bottom: var(--ch-bottom, 0px); padding: 8px 12px 8px; background: var(--bg); border-top: 1px solid var(--line); }
.ch-composer > * { max-width: 696px; margin-left: auto; margin-right: auto; }
.ch-box { display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 24px; box-shadow: 0 1px 2px rgba(11, 12, 14, 0.05), 0 6px 18px rgba(11, 12, 14, 0.07); transition: border-color 0.2s var(--ease); }
.ch-box:focus-within { border-color: var(--blue); }
.ch-box textarea { flex: 1; min-width: 0; min-height: 0; height: 42px; margin: 0; padding: 10px 0; border: 0; border-radius: 0; resize: none; background: none; box-shadow: none; outline: none; color: var(--text); font: 400 15px/1.45 var(--sans); }
.ch-box textarea::placeholder { color: var(--muted); }
.ch-send { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--ink); color: #FFFFFF; cursor: pointer; transition: background-color 0.2s var(--ease), transform 0.15s var(--ease); }
.ch-send:hover { background: var(--ink-hover); }
.ch-send:active { transform: scale(0.94); }
.ch-send svg { width: 20px; height: 20px; }
.ch-replying { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 6px 6px 6px 14px; border-radius: var(--radius-sm); background: var(--blue-tint); font-size: 13px; }
.ch-replying[hidden] { display: none; }
.ch-replying .grow { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.ch-replying .lead { flex: none; white-space: nowrap; }
.ch-replying .lead b { color: var(--blue); }
.ch-replying .snip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ch-note { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin-top: 6px; padding: 0 14px; font-size: 12px; color: var(--muted); }
.ch-note b { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--blue); }
.ch-note.flash { color: var(--text); }
@media (max-width: 519px) { .ch-note .ch-rules { display: none; } }
.ch-note.flash.ok { color: var(--ok); }
.ch-note.flash.ok b { color: var(--ok); }
.ch-new { position: fixed; z-index: 19; left: 50%; bottom: calc(var(--ch-space, 200px) - 8px); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 16px 8px 12px; border: 0; border-radius: 999px; background: var(--blue); color: #FFFFFF; font: 600 13px var(--sans); box-shadow: var(--shadow); cursor: pointer; animation: ch-pop 0.25s var(--ease); }
.ch-new svg { width: 18px; height: 18px; }
.ch-new[hidden] { display: none; }

/* Sem squad */
.ch-none { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.ch-none p { max-width: 60ch; }
.ch-none b { color: var(--blue); }

/* ---------- desktop: conversa a esquerda, squad e pontos a direita ---------- */
@media (min-width: 860px) {
  .ch-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 20px; align-items: start; }
  .ch-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 78px; }
  .ch-members { display: block; padding: 16px 18px 10px; }
  .ch-composer { padding: 10px 0 18px; border-top: 0; background: linear-gradient(to top, var(--bg) 82%, rgba(244, 245, 247, 0)); }
  .ch-composer > * { max-width: none; }
  .ch-new { left: calc(var(--ch-left, 50vw) + var(--ch-width, 0px) / 2); }
}
.ch-members h2 { font-size: 16px; margin-bottom: 4px; }
.ch-members ul { list-style: none; margin: 0; padding: 0; }
.ch-member { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.ch-member .avatar { width: 32px; height: 32px; }
.ch-member .grow { flex: 1; min-width: 0; }
.ch-member .grow b { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-member .grow span { display: block; font-size: 12px; color: var(--muted); }
.ch-member .grow span.online { color: var(--ok); }
.ch-member .pts { font-size: 13px; }

/* ---------- menu: item Equipe com contador de nao lidas ---------- */
.nav a.ch-nav { position: relative; }
.ch-badge-slot { display: contents; font-style: normal; }
.ch-badge { position: absolute; top: 2px; left: calc(50% + 7px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--orange); color: #FFFFFF; font: 700 11px/18px var(--mono); text-align: center; font-variant-numeric: tabular-nums; }
@media (min-width: 860px) { .ch-badge { position: static; margin-left: 2px; } }
/* Sete itens na barra inferior do celular: um pouco mais justos para os rotulos caberem. */
@media (max-width: 859px) {
  .nav:has(> a:nth-child(7)) a { font-size: 10px; letter-spacing: -0.01em; padding-left: 0; padding-right: 0; }
  .nav:has(> a:nth-child(7)) a svg { padding: 4px 10px; }
}
@media (max-width: 374px) { .nav:has(> a:nth-child(7)) a svg { padding: 4px 6px; } }
/* No topo azul do desktop, sete itens com icone nao cabem ao lado do logo, do Admin e dos pontos: so o texto. */
@media (min-width: 860px) {
  .nav:has(> a:nth-child(7)) a { padding: 8px 12px; }
  .nav:has(> a:nth-child(7)) a svg { display: none; }
}

/* ---------- atalhos: tela inicial e Ranking ---------- */
.ch-mission-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--blue-tint); color: var(--blue); }
.ch-mission-icon svg { width: 20px; height: 20px; }
.ch-mission.unread .ch-mission-icon { background: var(--blue); color: #FFFFFF; }
.ch-mission .grow span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ch-count { flex: none; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--orange); color: #FFFFFF; font: 700 13px/26px var(--mono); text-align: center; font-variant-numeric: tabular-nums; }
.rk-chat { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; margin-top: 8px; padding: 8px 16px 8px 12px; border: 1px solid rgba(255, 255, 255, 0.42); border-radius: 999px; color: #FFFFFF; font-size: 15px; font-weight: 600; text-decoration: none; transition: background-color 0.2s var(--ease); }
.rk-chat:hover { background: rgba(255, 255, 255, 0.12); }
.rk-chat svg { width: 18px; height: 18px; }
.rk-chat b { color: var(--logo-cyan); font-weight: 700; }

/* ---------- Admin: aba Chat das equipes ---------- */
.ch-adm-team .grow, .ch-adm-msg .grow { flex: 1; min-width: 180px; }
.ch-adm-team .grow b, .ch-adm-msg .grow b { display: block; }
.ch-adm-team .grow span, .ch-adm-msg .grow span { display: block; font-size: 13px; color: var(--muted); }
.ch-adm-team.on { border-color: var(--blue); }
.ch-adm-num { font-size: 13px; color: var(--muted); white-space: nowrap; }
.ch-adm-num b { font-family: var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.ch-adm-msg .grow span { color: var(--text); font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-adm-msg.deleted .grow span { color: var(--muted); }
.ch-adm-msg time { font: 400 12px var(--mono); color: var(--muted); margin-left: 6px; }
.ch-logs { list-style: none; margin: 0; padding: 6px 16px; max-height: 520px; overflow-y: auto; }
.ch-log { display: flex; align-items: baseline; gap: 12px; padding: 8px 0; font-size: 13px; }
.ch-log + .ch-log { border-top: 1px solid var(--line); }
.ch-log time { flex: none; font: 400 12px var(--mono); color: var(--muted); }
.ch-log .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ch-log-detail { color: var(--muted); }
.ch-log-team { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.ch-log .pts { font-size: 12px; }
.ch-log .pts.neg { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .ch-picker, .ch-new { animation: none; } }
