/* ---------- Brave Chat · cores da Brave Defender ----------
   Laranja #F06D11 · Azul #022369 · Âmbar #FFA600 · Preto #171616 · Creme #FFFDFA
   Azul médio #234EAA · Teal #38BFC2 · Pêssego #FFF6EE · Borda #D9DEEA · Texto 2 #5A5650 */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/BricolageGrotesque.ttf?v=1") format("truetype");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --bg: #fffdfa;
  --panel: #ffffff;
  --head: #022369;          /* topo azul, como no exemplo de conversa do kit */
  --head-text: #fffdfa;
  --head-muted: rgba(255, 253, 250, .7);
  --in: #ffffff;
  --in-border: #d9deea;
  --out: #f06d11;
  --out-border: #f06d11;
  --out-text: #fffdfa;
  --out-muted: rgba(255, 253, 250, .8);
  --text: #171616;
  --muted: #5a5650;
  --accent: #f06d11;
  --accent-2: #f06d11;
  --amber: #ffa600;
  --accent-ink: #ffffff;
  --soft: #fff6ee;
  --soft-text: #c2560a;
  --lilac-soft: #eef2fb;
  --lilac-text: #234eaa;
  --line: #d9deea;
  --danger: #c93a2b;
  --danger-soft: #fdecea;
  --shadow: 0 8px 28px rgba(2, 35, 105, .12);
  --av-l: 91%;           /* luminosidade do fundo dos avatares */
  --name-l: 38%;         /* luminosidade da cor dos @números */
  --quote-mine: rgba(255, 255, 255, .18);
  --toast-bg: #022369;
  --toast-fg: #fffdfa;
  color-scheme: light;
}

/* ---------- modo escuro (azul Brave) ---------- */
:root[data-theme="dark"] {
  --bg: #061331;
  --panel: #0c1d47;
  --head: #022369;
  --head-text: #fffdfa;
  --head-muted: rgba(255, 253, 250, .68);
  --in: #12275a;
  --in-border: #1f3a7a;
  --out: #f06d11;
  --out-border: #f06d11;
  --out-text: #fffdfa;
  --out-muted: rgba(255, 253, 250, .78);
  --text: #f4f2ee;
  --muted: #a7b1c9;
  --accent: #ff8a3d;
  --accent-2: #ff8a3d;
  --amber: #ffa600;
  --soft: #2a1d17;
  --soft-text: #ffb27a;
  --lilac-soft: #12275a;
  --lilac-text: #cfdaf5;
  --line: #1f3a7a;
  --danger: #ff7a7a;
  --danger-soft: #3a1820;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --av-l: 30%;
  --name-l: 74%;
  --quote-mine: rgba(0, 0, 0, .18);
  --toast-bg: #fffdfa;
  --toast-fg: #171616;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #061331;
    --panel: #0c1d47;
    --head: #022369;
    --head-text: #fffdfa;
    --head-muted: rgba(255, 253, 250, .68);
    --in: #12275a;
    --in-border: #1f3a7a;
    --out: #f06d11;
    --out-border: #f06d11;
    --out-text: #fffdfa;
    --out-muted: rgba(255, 253, 250, .78);
    --text: #f4f2ee;
    --muted: #a7b1c9;
    --accent: #ff8a3d;
    --accent-2: #ff8a3d;
    --amber: #ffa600;
    --soft: #2a1d17;
    --soft-text: #ffb27a;
    --lilac-soft: #12275a;
    --lilac-text: #cfdaf5;
    --line: #1f3a7a;
    --danger: #ff7a7a;
    --danger-soft: #3a1820;
    --shadow: 0 8px 28px rgba(0, 0, 0, .45);
    --av-l: 30%;
    --name-l: 74%;
    --quote-mine: rgba(0, 0, 0, .18);
    --toast-bg: #fffdfa;
    --toast-fg: #171616;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font: 15px/1.4 "Bricolage Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
/* a página em si nunca faz scroll: só as áreas de dentro (lista, formulários) */
body { position: fixed; inset: 0; width: 100%; }

.app {
  display: flex;
  flex-direction: column;
  /* altura = parte visível do ecrã (encolhe quando o teclado abre; ver app.js) */
  position: fixed;
  top: var(--app-top, 0px);
  left: 0;
  right: 0;
  height: 100vh;
  height: var(--app-h, 100dvh);
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
  background-color: var(--bg);   /* liso: nada de imagens/gradientes no contentor do topo */
}

.page { background-color: var(--bg); }

/* o padrão às bolinhas fica só na lista de mensagens, nunca no topo do ecrã */
.list {
  background:
    radial-gradient(circle at 12px 12px, rgba(224, 69, 123, .07) 1.5px, transparent 2px) 0 0 / 26px 26px,
    var(--bg);
}

/* ---------- topo do chat ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.room-avatar { width: 38px; height: 38px; border-radius: 50%; display: block; }
.room-info { flex: 1; min-width: 0; }
.room-info h1 { margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-info p { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-btn { background: none; border: 0; padding: 0; cursor: pointer; }
.icon-btn {
  background: var(--soft); border: 0; border-radius: 50%;
  width: 38px; height: 38px; display: grid; place-items: center;
  font-size: 19px; cursor: pointer; flex-shrink: 0;
}

/* ---------- avatares ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 19px; line-height: 1;
  flex-shrink: 0;
}
.avatar.sm { width: 38px; height: 38px; font-size: 21px; box-shadow: 0 0 0 2px var(--accent); }
.avatar.xl { width: 96px; height: 96px; font-size: 54px; margin: 0 auto; box-shadow: 0 0 0 3px var(--accent); }

/* ---------- barras de aviso (instalar / notificações) ---------- */
.install-bar, .notif-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: var(--lilac-soft);
  color: var(--lilac-text);
  font-size: 13px;
  flex-shrink: 0;
}
.install-bar span, .notif-bar span { flex: 1; }
.install-bar button, .notif-bar button {
  background: var(--accent-2); color: #fff; border: 0; border-radius: 16px;
  padding: 6px 12px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.install-bar .x, .notif-bar .x { background: none; color: var(--lilac-text); padding: 4px 6px; }

/* ---------- lista de mensagens ---------- */
.list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 10px;
  display: flex;
  flex-direction: column;
}
.notice {
  align-self: center;
  max-width: 440px;
  margin: 6px 8px 14px;
  padding: 9px 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--soft-text);
  border-radius: 12px;
  font-size: 12.5px;
  text-align: center;
}
.notice .tip { color: var(--muted); font-size: 11.5px; }
.day {
  align-self: center;
  margin: 10px 0 8px;
  padding: 4px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  font-size: 12px;
}

.row { display: flex; align-items: flex-end; gap: 6px; margin-top: 3px; max-width: 100%; position: relative; }
.row.first { margin-top: 10px; }
.row.has-reacts { margin-bottom: 14px; }
.row.mine { justify-content: flex-end; }
.row .avatar { visibility: hidden; }
.row.last .avatar { visibility: visible; }
.row.mine .avatar { display: none; }

.bubble {
  position: relative;
  max-width: min(78%, 560px);
  padding: 6px 9px 6px 10px;
  border-radius: 16px;
  background: var(--in);
  border: 1px solid var(--in-border);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  cursor: pointer;
  user-select: text;
  box-shadow: 0 1px 2px rgba(122, 52, 96, .06);
  transition: transform .15s ease, box-shadow .2s;
}
.row.mine .bubble { background: var(--out); border-color: var(--out-border); }
.row.first .bubble { border-top-left-radius: 5px; }
.row.mine.first .bubble { border-top-left-radius: 16px; border-top-right-radius: 5px; }
.bubble.flash, .bubble.selected { box-shadow: 0 0 0 2px var(--accent); }

.who { font-size: 12.5px; font-weight: 700; margin-bottom: 1px; }
.who .real { color: var(--muted); font-weight: 500; }
.row:not(.first) .who, .row.mine .who { display: none; }

.time {
  float: right;
  margin: 6px 0 -4px 10px;
  font-size: 11px;
  color: var(--muted);
}
.row.pending .bubble { opacity: .6; }

/* resposta citada dentro do balão */
.quote {
  display: block;
  border-left: 3px solid var(--q, var(--accent));
  background: rgba(224, 69, 123, .06);
  border-radius: 8px;
  padding: 4px 8px;
  margin: 2px 0 5px;
  white-space: normal;
  min-width: 0;
}
.row.mine .bubble .quote { background: var(--quote-mine); }
.q-who { font-size: 12px; font-weight: 700; color: var(--q, var(--accent)); }
.q-text { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* reações por baixo do balão */
.reacts {
  position: absolute;
  bottom: -14px;
  left: 10px;
  display: flex; gap: 2px;
  padding: 1px 6px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(122, 52, 96, .1);
}
.row.mine .reacts { left: auto; right: 10px; }
.reacts .n { font-size: 11.5px; color: var(--muted); margin-left: 2px; }
.reacts.mine-react { border-color: var(--accent); }

.swipe-hint {
  position: absolute; left: -30px; top: 50%;
  transform: translateY(-50%);
  color: var(--accent); font-size: 18px; opacity: 0;
}

/* ---------- menu reagir / responder ---------- */
.menu {
  position: fixed;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.menu-reacts { display: flex; gap: 2px; }
.menu-reacts button {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; font-size: 24px; cursor: pointer;
}
.menu-reacts button:hover { background: var(--soft); }
.menu-reacts button.on { background: var(--soft); box-shadow: inset 0 0 0 2px var(--accent); }
.menu-reply {
  border: 0; border-top: 1px solid var(--line);
  background: none; color: var(--text);
  padding: 9px; font: inherit; font-weight: 600; cursor: pointer; border-radius: 0 0 12px 12px;
}
.menu-reply:hover { color: var(--accent); }

/* ---------- ligação ---------- */
.conn {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 4px; background: var(--soft); flex-shrink: 0;
}

/* ---------- resposta (acima do campo) ---------- */
.reply-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 10px;
  padding: 6px 6px 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  flex-shrink: 0;
}
.reply-bar .quote { flex: 1; margin: 0; }
.reply-bar .x { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 6px 8px; cursor: pointer; }

/* ---------- escrever ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* evita zoom no iOS */
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.composer textarea::placeholder { color: var(--muted); }
.composer button {
  width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}

/* teclado aberto: a barra do iPhone fica tapada pelo teclado, não precisa de margem */
.kb .composer { padding-bottom: 8px; }
.kb .page { padding-bottom: 16px; }

/* ---------- folhas (diálogos) ---------- */
.sheet {
  border: 0; border-radius: 22px; padding: 0;
  background: var(--panel); color: var(--text);
  width: min(92vw, 360px);
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(45, 36, 51, .35); }
.sheet-body { padding: 24px 20px 18px; text-align: center; }
.me-name { font-size: 26px; font-weight: 800; margin: 14px 0 4px; }
.muted { color: var(--muted); font-size: 13.5px; }
.btn {
  display: block; width: 100%; margin-top: 10px;
  padding: 13px; border-radius: 26px; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(240, 109, 17, .25);
}
.btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; }

/* =========================================================
   Ecrãs: início, admin, convite
   ========================================================= */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.page {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 calc(env(safe-area-inset-bottom) + 24px);
}
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.small { font-size: 12.5px; }

.hero { text-align: center; padding: calc(env(safe-area-inset-top) + 40px) 20px 18px; }
.hero img { width: 116px; height: 116px; border-radius: 30px; box-shadow: var(--shadow); }
.hero h1 {
  margin: 18px 0 2px; font-size: 30px; font-weight: 800; letter-spacing: -.3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 0; color: var(--muted); }

.page .install-bar { margin: 6px 16px 0; border-radius: 14px; }

.choices { display: flex; flex-direction: column; gap: 10px; padding: 22px 16px 0; max-width: 460px; width: 100%; margin: 0 auto; }
a.btn { text-decoration: none; text-align: center; }
.btn.alt { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.sm { padding: 9px 12px; margin-top: 0; font-size: 14px; }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }

.label { margin: 22px 16px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.sheet .label { margin: 16px 0 6px; }

.cards { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  color: var(--text); text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 3px rgba(122, 52, 96, .06);
}
.card:active { background: var(--soft); }
.card .ci { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; }
.card .ct { flex: 1; min-width: 0; }
.card .ct b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .ct span { font-size: 12.5px; color: var(--muted); }
.card .go { color: var(--muted); font-size: 22px; }

/* barra de topo das páginas */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.bar h1 { margin: 0; font-size: 17px; font-weight: 700; }
.bar .sub { margin: 0; font-size: 12px; color: var(--accent); }
.back {
  color: var(--accent); text-decoration: none; font-size: 34px; line-height: 1;
  padding: 0 8px 4px 2px; font-weight: 300;
}
.top .back { padding-right: 0; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 6px; }

/* formulários */
.form { display: flex; flex-direction: column; gap: 14px; padding: 20px 16px; max-width: 460px; width: 100%; margin: 0 auto; }
.form.inline { flex-direction: row; align-items: center; gap: 8px; max-width: 560px; }
.form.inline input { flex: 1; min-width: 0; }
.form.inline .btn { width: auto; margin: 0; padding: 12px 18px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.form input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); color: var(--text);
  font: inherit; font-size: 16px; outline: none;
}
.form input:focus { border-color: var(--accent); }
.at { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.at:focus-within { border-color: var(--accent); }
.at span { padding-left: 14px; color: var(--accent); font-weight: 800; font-size: 18px; }
.at input { border: 0; background: transparent; padding-left: 4px; font-size: 18px; font-weight: 700; }
.err { margin: 0; color: var(--danger); font-size: 13.5px; }
.group-chip { padding: 10px 14px; border-radius: 14px; background: var(--soft); color: var(--soft-text); }
.form.center { align-items: stretch; text-align: center; }

/* folha de convite + membros */
.sheet.wide { width: min(94vw, 440px); max-height: 86vh; }
.sheet-body.left { text-align: left; }
.sheet-title { margin: 0 0 6px; font-size: 20px; cursor: pointer; }
.invite-box { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-top: 10px; }
.invite-box .label { margin: 0 0 6px; }
.code { font-size: 28px; font-weight: 800; letter-spacing: 4px; color: var(--accent); font-family: ui-monospace, Menlo, monospace; }
.link-text { font-size: 12.5px; color: var(--muted); word-break: break-all; margin: 4px 0 10px; }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; }
.invite-box .link { margin-top: 6px; padding: 4px 0; font-size: 12.5px; }
.members { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 6px; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg); border-radius: 14px; }
.member .mt { flex: 1; min-width: 0; }
.member .mt b { display: block; }
.member .mt span { font-size: 13px; color: var(--muted); }
.member .kick { background: none; border: 0; color: var(--danger); font-size: 13px; cursor: pointer; }
.member.is-admin { border: 1px solid var(--out-border); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px);
  transform: translateX(-50%);
  background: var(--toast-bg); color: var(--toast-fg);
  padding: 9px 16px; border-radius: 20px; font-size: 14px; z-index: 30;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- iPhone (iOS 26+): desfocado do sistema no topo ----------
   O iOS desenha um "vidro" desfocado por cima da barra da hora e ~40pt abaixo dela.
   1) faixa de cor lisa por trás da barra, para não haver nada para desfocar;
   2) se a app estiver por baixo da barra (instalações antigas), o conteúdo do topo
      desce para fora da zona desfocada (classe .ios-pad, posta pelo app.js). */
.sb-cover {
  position: fixed; top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top);
  background-color: var(--bg);
  z-index: 50;
  pointer-events: none;
}
.ios-pad .sb-cover { height: calc(env(safe-area-inset-top) + 40px); }
.ios-pad .top, .ios-pad .bar { padding-top: calc(env(safe-area-inset-top) + 50px); }
.ios-pad .hero { padding-top: calc(env(safe-area-inset-top) + 60px); }
.ios-pad .bar { position: relative; z-index: 51; background: transparent; border-bottom: 0; }
.ios-pad .top { position: relative; z-index: 51; background: transparent; border-bottom: 0; }
.ios-pad .app { background-color: var(--panel); }

/* mensagens apagadas */
.menu-reply.danger-text { color: var(--danger); border-top: 0; padding-top: 4px; }
.row.deleted .bubble { background: var(--panel); border-style: dashed; cursor: default; }
.row.deleted .deleted-text { color: var(--muted); font-style: italic; }
.q-text.gone { font-style: italic; }

/* escolha de aparência */
.appearance { max-width: 460px; width: 100%; margin: 6px auto 0; padding: 0 16px; }
.appearance .label { margin-left: 0; }
.theme-pick {
  display: flex; gap: 4px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.theme-pick button {
  flex: 1; border: 0; border-radius: 12px; padding: 9px 4px;
  background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.theme-pick button.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.sheet .theme-pick { margin-bottom: 4px; }

/* =========================================================
   Guia de instalação (só no browser)
   ========================================================= */
.howto {
  max-width: 460px; width: calc(100% - 32px); margin: 8px auto 0;
  padding: 16px 14px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 2px 10px rgba(122, 52, 96, .07);
}
.howto-head h2 { margin: 0 0 4px; font-size: 18px; }
.howto-head p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; }
.howto #installNow { margin: 0 0 12px; }
.howto-warn {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--danger-soft); color: var(--danger); font-size: 13.5px;
}
.howto-tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
}
.howto-tabs button {
  flex: 1; border: 0; border-radius: 10px; padding: 8px 2px;
  background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.howto-tabs button.on { background: var(--panel); color: var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.howto-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.howto-step {
  display: grid; grid-template-columns: 24px max-content 1fr; align-items: center; gap: 10px;
  padding: 8px; border-radius: 14px; background: var(--bg);
}
.howto-step .num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; font-size: 13px;
}
.howto-step p { margin: 0; font-size: 14px; line-height: 1.4; }
.howto-note { margin: 10px 2px 4px; font-size: 12.5px; color: var(--muted); }
.howto .link { display: block; margin: 2px auto 0; }
.kbd {
  display: inline-block; min-width: 18px; padding: 0 4px; border-radius: 5px; text-align: center;
  background: var(--soft); color: var(--accent); font-weight: 700;
}

/* desenhos dos ecrãs */
.mk { width: 92px; height: auto; display: block; overflow: visible; }
.mk.wide { width: 128px; }
.mk .f { fill: var(--panel); stroke: var(--line); stroke-width: 2; }
.mk .s { fill: var(--bg); }
.mk .mbar { fill: var(--in); }
.mk .mpill { fill: var(--bg); stroke: var(--line); }
.mk .g { fill: var(--line); }
.mk .mdim { fill: rgba(0, 0, 0, .25); }
.mk .msheet { fill: var(--panel); stroke: var(--line); }
.mk .mrow { fill: var(--bg); }
.mk .mrow.on { fill: var(--soft); }
.mk .btnk { fill: var(--accent); }
.mk .tog { fill: #34c759; }
.mk .togk { fill: #fff; }
.mk text { font: 600 7px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--text); }
.mk .tm { fill: var(--muted); font-weight: 500; }
.mk .tb { fill: var(--accent); font-weight: 800; }
.mk .tw { fill: #fff; font-weight: 800; }
.mk .ti { font-size: 13px; fill: var(--text); }
.mk .ic { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mk .hl {
  fill: none; stroke: var(--accent); stroke-width: 2.5;
  animation: hlpulse 1.4s ease-in-out infinite;
}
@keyframes hlpulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .mk .hl { animation: none; } }
.mk .ts { font-size: 6.2px; }

/* papéis */
.read-only {
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--panel); border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13.5px; text-align: center; flex-shrink: 0;
}
.read-only b { color: var(--accent); }
.role-badge {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 10px; background: var(--soft); color: var(--accent); flex-shrink: 0;
}
.member { flex-wrap: wrap; }
.m-acts { display: flex; gap: 10px; width: 100%; padding-left: 44px; }
.member .promote { background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 2px 0; }

/* =========================================================
   Brave Defender: fundo igual de cima abaixo, mensagens laranja
   ========================================================= */
.top, .bar { background: var(--bg); border-bottom: 1px solid var(--line); color: var(--text); }
.top .room-info h1, .bar h1 { color: var(--text); }
.top .room-info p { color: var(--muted); }
.top .back, .bar .back { color: var(--accent); }
.bar .sub { color: var(--accent); }
.bar .link { color: var(--accent); }
.top .icon-btn { background: var(--soft); }
.avatar.sm { box-shadow: 0 0 0 2px var(--accent); }
.ios-pad .top, .ios-pad .bar { background: var(--bg); }
.sb-cover, .ios-pad .sb-cover { background-color: var(--bg); }
.composer, .read-only { background: var(--bg); }

h1, h2, .me-name, .code, .sheet-title, .howto-head h2 { font-family: "Bricolage Grotesque", -apple-system, sans-serif; letter-spacing: -.2px; }
.who, .q-who { letter-spacing: .1px; }

/* as minhas mensagens: laranja com texto creme */
.row.mine .bubble { background: var(--out); border-color: var(--out-border); color: var(--out-text); }
.row.mine .time { color: var(--out-muted); }
.row.mine .bubble .quote { background: var(--quote-mine); border-left-color: var(--out-text); }
.row.mine .bubble .q-who { color: var(--out-text); }
.row.mine .bubble .q-text { color: var(--out-muted); }
.row.mine.deleted .bubble { background: var(--panel); color: var(--muted); border-color: var(--line); }

/* ecrã inicial: faixa azul com o logótipo, como no kit de marca */
/* ecrã inicial: fundo neutro, logótipo + "Brave" (texto) "Chat" (laranja) */
.hero { background: transparent; color: var(--text); padding-bottom: 14px; }
.hero img { box-shadow: 0 10px 30px rgba(2, 35, 105, .22); }
/* título em estilo logótipo: "Brave" extra bold + "chat" leve, mesma letra e mesma largura */
.hero h1.wordmark {
  background: none; -webkit-background-clip: border-box; background-clip: border-box;
  margin: 16px 0 4px;
  color: var(--text); font-size: 44px; line-height: 1; letter-spacing: -1.4px;
  font-weight: 800; font-stretch: 100%;
  font-variation-settings: "wght" 800, "wdth" 100, "opsz" 72;
}
.hero h1.wordmark span {
  color: var(--accent); letter-spacing: -.9px; margin-left: 1px;
  font-weight: 340; font-stretch: 100%;
  font-variation-settings: "wght" 340, "wdth" 100, "opsz" 72;
}
.hero p { color: var(--muted); }

/* botões: laranja liso da marca */
.btn, .composer button, .theme-pick button.on, .howto-step .num { background: var(--accent); }
.btn.alt { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm.alt { background: var(--panel); }
.howto-tabs button.on { color: var(--accent); }
.install-bar button, .notif-bar button { background: #234eaa; }
.notif-bar, .install-bar { background: var(--lilac-soft); color: var(--lilac-text); }
.code { color: var(--accent); }
.group-chip { background: var(--soft); color: var(--soft-text); }
.mk .tog { fill: #38bfc2; }
.mk text { font-family: "Bricolage Grotesque", -apple-system, sans-serif; }

/* seta de voltar: desenho do sistema (a Bricolage tem um ‹ muito fino) */
.back, .card .go { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-weight: 400; }


/* botões com ícone desenhado */
.btn.with-icon { display: flex; align-items: center; justify-content: center; gap: 9px; }
.bi { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.btn.alt .bi { stroke: var(--accent); }

/* "Como instalar a app?" com mais destaque */
#howtoShow {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 20px;
  background: var(--soft); color: var(--soft-text); border: 1px solid rgba(240, 109, 17, .35);
  font-size: 14px; font-weight: 700;
}

/* dica no topo do chat (só o que cada um pode fazer) */
.notice.tip-only { color: var(--muted); }
.notice.tip-only b { color: var(--accent); }

/* enviar foto */
.attach {
  width: 42px !important; height: 46px !important; flex-shrink: 0;
  background: transparent !important; color: var(--accent) !important;
  border: 0; display: grid; place-items: center; cursor: pointer; border-radius: 50%;
}
.attach .bi { width: 24px; height: 24px; }

/* fotos nas mensagens */
.msg-img {
  display: block; max-width: 100%; width: 260px; max-height: 340px; object-fit: cover;
  border-radius: 12px; margin: 2px 0 6px; cursor: zoom-in; background: var(--soft);
}
.msg-img.uploading { height: 140px; display: grid; place-items: center; color: var(--muted); font-size: 13px; cursor: default; }
.row.mine .msg-img.uploading { color: var(--out-muted); background: rgba(255, 255, 255, .15); }

/* ver foto em grande */
.viewer {
  border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh;
  width: 100vw; height: 100vh; display: none;
}
.viewer[open] { display: grid; place-items: center; }
.viewer::backdrop { background: rgba(0, 0, 0, .92); }
.viewer img { max-width: 96vw; max-height: 90vh; border-radius: 10px; }

/* foto do grupo */
.group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.group-photo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--line); }
.group-head .link { display: block; padding: 2px 0; font-size: 13px; }
.muted-link { color: var(--muted) !important; }
.room-avatar { object-fit: cover; }
.card img.ci { object-fit: cover; }

/* criar grupo com foto */
.form.create { gap: 8px; max-width: 560px; }
.form.create .muted { margin: 0 2px; }
.form.create .btn { margin-top: 4px; }
.create-row { display: flex; align-items: center; gap: 12px; }
.create-row input { flex: 1; min-width: 0; }
.new-photo {
  position: relative; width: 58px; height: 58px; flex-shrink: 0;
  border: 0; padding: 0; border-radius: 50%; cursor: pointer; background: none;
}
.new-photo img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; display: block; border: 1px solid var(--line); }
.new-photo .cam {
  position: absolute; right: -2px; bottom: -2px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
  background: var(--accent); box-shadow: 0 0 0 2px var(--bg);
}
.new-photo.has-photo .cam { background: var(--panel); }

/* topo do chat: foto + nome do grupo abrem as definições */
.group-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 2px 4px 2px 0; margin: 0; text-align: left;
  color: inherit; font: inherit; cursor: pointer; border-radius: 12px;
}
.group-btn:active { background: var(--soft); }
.group-btn .room-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.room-title {
  font-family: "Bricolage Grotesque", -apple-system, sans-serif;
  font-size: 17px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-btn .bi { width: 21px; height: 21px; stroke: var(--accent); }
#gdAdminTools .link { display: block; padding: 2px 0; font-size: 13px; }
#gdMembers .btn.alt { margin-top: 8px; }

/* painel de admin: "Os teus grupos" + botão + */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 560px; margin: 0 auto; padding: 14px 16px 4px;
}
.section-head .label { margin: 8px 0; }
.plus-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 26px; line-height: 1; font-weight: 400;
  display: grid; place-items: center; padding-bottom: 3px;
  box-shadow: 0 6px 16px rgba(240, 109, 17, .25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#admEmpty { margin-top: 28px; line-height: 1.6; }

/* janela "Novo grupo" */
.create-sheet { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.create-sheet .sheet-title { align-self: flex-start; }
.create-sheet .muted { margin: 0 0 4px; }
.create-sheet .btn { margin-top: 2px; }
.new-photo.big, .new-photo.big img { width: 104px; height: 104px; }
.new-photo.big .cam { width: 32px; height: 32px; font-size: 15px; right: 0; bottom: 0; }
.field {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px; outline: none;
}
.field:focus { border-color: var(--accent); }

/* editor de enquadramento */
.crop-sheet .sheet-body { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.crop-sheet .sheet-title, .crop-sheet .muted { margin: 0; }
.crop-stage {
  position: relative; width: min(78vw, 300px); aspect-ratio: 1; overflow: hidden;
  border-radius: 16px; background: #000; touch-action: none; cursor: grab; user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
/* máscara: escurece tudo fora do círculo */
.crop-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .55), inset 0 0 0 2px rgba(255, 255, 255, .85);
}
.crop-zoom { width: min(78vw, 300px); accent-color: var(--accent); }

/* ---------- janelas acima do teclado ----------
   As janelas ficam centradas só na parte visível do ecrã (acima do teclado, em iPhone e Android),
   e fazem scroll por dentro se não couberem. */
dialog.sheet {
  position: fixed;
  top: var(--app-top, 0px);
  bottom: var(--app-bottom, 0px);
  margin: auto;
  max-height: calc(var(--app-h, 100dvh) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ícones da interface: todos com o mesmo traço */
.bi { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -4px; }
.icon-btn { color: var(--accent); }
.icon-btn .bi { width: 21px; height: 21px; }
.theme-pick button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.theme-pick button .bi { width: 17px; height: 17px; }
.menu-reply { display: flex; align-items: center; justify-content: center; gap: 8px; }
.menu-reply .bi { width: 18px; height: 18px; }
.link .bi, .promote .bi { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; }
#gdAdminTools .link, #mdNewCode { display: inline-flex; align-items: center; }
#howtoShow .bi { width: 17px; height: 17px; margin-right: 2px; }
.howto-head h2 { display: flex; align-items: center; gap: 8px; }
.howto-head h2 .bi { width: 22px; height: 22px; color: var(--accent); }
.note-ic { display: flex; align-items: flex-start; gap: 8px; }
.note-ic .bi { width: 16px; height: 16px; margin-top: 1px; color: var(--accent); }
.read-only.note-ic { justify-content: center; align-items: center; }
.notif-bar .note-ic { align-items: center; }
.howto-warn { display: flex; gap: 8px; align-items: flex-start; }
.howto-warn .bi { width: 18px; height: 18px; flex-shrink: 0; }
.new-photo .cam .bi { width: 15px; height: 15px; color: #fff; vertical-align: 0; }
.new-photo.big .cam .bi { width: 17px; height: 17px; }
.new-photo.has-photo .cam .bi { color: var(--accent); }
.notice.tip-only .bi { width: 16px; height: 16px; color: var(--accent); vertical-align: -3px; }
.plus-btn { padding: 0; }
.plus-btn .bi { width: 22px; height: 22px; stroke-width: 2.4; color: #fff; }

/* "+" com mais espaço em relação aos grupos */
.section-head { padding: 18px 16px 14px; }

/* topo do chat: nome centrado ao lado da foto */
.group-btn .room-info { justify-content: center; }

/* tirar foto do grupo: x pequeno no canto da foto */
.photo-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.photo-x {
  position: absolute; top: -4px; right: -4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--text); color: var(--bg); box-shadow: 0 0 0 2px var(--panel);
}
.photo-x .bi { width: 13px; height: 13px; stroke-width: 2.6; vertical-align: 0; }

/* "a escrever…" por baixo do nome do grupo */
.room-sub.typing { color: var(--accent); font-weight: 600; animation: typingPulse 1.2s ease-in-out infinite; }
@keyframes typingPulse { 50% { opacity: .55; } }

/* painel de admin: arrastar o grupo para a esquerda → Apagar */
.swipe-row { position: relative; border-radius: 16px; overflow: hidden; transition: opacity .25s, transform .25s; }
.swipe-row .card { position: relative; z-index: 1; touch-action: pan-y; background: var(--panel); }
.swipe-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 96px; border: 0; cursor: pointer;
  background: var(--danger); color: #fff; font: inherit; font-size: 13px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.swipe-del .bi { width: 20px; height: 20px; }
.swipe-row.removing { opacity: 0; transform: translateX(-30%); }
.swipe-del { opacity: 0; transition: opacity .15s; }
.swipe-row.open .swipe-del { opacity: 1; }

/* código de admin: maiúsculas/minúsculas tanto faz → esconder o aviso de Caps Lock do Safari (ficava achatado) */
input[type="password"]::-webkit-caps-lock-indicator { content: none; display: none; }
input[type="password"]::-webkit-credentials-auto-fill-button { flex-shrink: 0; }
.field-hint { margin: -6px 2px 0; }

/* à espera de aprovação */
.pending-box {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center;
}
.pending-box h2 { margin: 12px 0 0; }
.pending-box p { max-width: 300px; margin: 0; }
/* pedidos (admins) */
.member.request { border: 1px dashed var(--accent); }
.member .approve { background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 2px 0; display: inline-flex; align-items: center; gap: 4px; }
.member .approve .bi { width: 15px; height: 15px; }
/* ponto com o nº de pedidos na foto do grupo */
.group-btn { position: relative; }
.group-btn.has-requests::after {
  content: attr(data-req); position: absolute; left: 26px; top: -2px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* página de privacidade */
.doc-body { position: static; overflow: auto; height: auto; }
.doc { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 20px) 20px 48px; line-height: 1.55; }
.doc h1 { font-size: 30px; margin: 14px 0 6px; }
.doc h2 { font-size: 18px; margin: 26px 0 6px; }
.doc ul { padding-left: 20px; margin: 6px 0; }
.doc li { margin: 4px 0; }
.doc a, .home-foot a { color: var(--accent); }
.doc-back { text-decoration: none; font-weight: 700; }
html:has(.doc-body) { overflow: auto; }
.home-foot { margin: 22px 0 0; font-size: 13px; }

.note-ic .note-txt { flex: 1; min-width: 0; }
.read-only.note-ic .note-txt { flex: 0 1 auto; }
