/* ============================================================================
   YiuChat — Folha de estilos (mobile-first, temas claro/escuro)
   ============================================================================
   ORGANIZAÇÃO:
     1. Fonte Inter (self-hosted) + variáveis e temas
     2. Reset e base
     3. Splash / loading
     4. Shell do app (header, main, footer) + safe-area (WebView/APK)
     5. Ícones SVG — assets/icons/*.svg via mask (currentColor)
     6. Bandeiras 100% CSS (Brasil, Espanha, Inglaterra)
     7. Tela HOME
     8. Tela AGUARDANDO (sala criada)
     9. Tela CHAT (bolhas, composer, emojis, gravação, digitando...)
    10. Modais (informação/progresso/confirmação/anexo)
    11. Scrollbars personalizadas (minimalistas)
    12. Animações
    13. Ajustes de desktop (container centralizado)
   ============================================================================ */

/* ==================== 0. FONTE (Inter, self-hosted) ====================
   Nenhum recurso externo: os woff2 estão em assets/fonts/. Fonte variável —
   um único par latin/latin-ext cobre os pesos 100–900 usados na interface.
   Licença SIL OFL 1.1 (livre para uso/comercial). */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ==================== 1. TEMAS ==================== */
:root {
  --primary:       #0a7de1;
  --primary-2:     #0d8af3;
  --primary-grad:  linear-gradient(135deg, #0a7de1 0%, #2f9ff5 100%);
  --danger:        #e5484d;
  --orange:        #ff9f1c;
  --green:         #10b981;
  --green-2:       #34d399;
  --green-grad:    linear-gradient(135deg, #10b981 0%, #34d399 100%);

  --bg:            #ffffff;
  --bg-soft:       #f0f4f9;
  --chat-bg:       #eef3f9;
  --surface:       #ffffff;
  --surface-2:     #f5f8fc;
  --border:        #e3eaf2;

  --text:          #16202c;
  --text-soft:     #5b6b7d;
  --text-faint:    #8a9ab0;

  --bubble-out:    var(--primary-grad);
  --bubble-out-tx: #ffffff;
  --bubble-in:     #ffffff;
  --bubble-in-tx:  #16202c;
  --bubble-time:   rgba(90, 110, 130, .78);

  --shadow:        0 6px 24px rgba(20, 45, 80, .10);
  --shadow-sm:     0 2px 8px rgba(20, 45, 80, .08);

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --radius:      16px;
  --radius-sm:   10px;
  --header-h:    58px;

  --scroll-thumb: rgba(90, 110, 130, .35);
  --scroll-track: transparent;
}

/* Tema escuro (classe no <html>) */
html[data-theme="dark"] {
  --primary:       #3b9df8;
  --primary-2:     #5db2ff;
  --primary-grad:  linear-gradient(135deg, #2f8ef4 0%, #5db2ff 100%);
  --danger:        #f2555b;
  --green:         #34d399;
  --green-2:       #4ade80;
  --green-grad:    linear-gradient(135deg, #0d9488 0%, #4ade80 100%);

  --bg:            #0e141b;
  --bg-soft:       #131c26;
  --chat-bg:       #0e141b;
  --surface:       #1a2430;
  --surface-2:     #212d3b;
  --border:        #2a3849;

  --text:          #e8eef5;
  --text-soft:     #9db0c4;
  --text-faint:    #6a7f96;

  --bubble-out:    linear-gradient(135deg, #1b6fd8 0%, #2f8ef4 100%);
  --bubble-out-tx: #ffffff;
  --bubble-in:     #1a2430;
  --bubble-in-tx:  #e8eef5;
  --bubble-time:   rgba(190, 205, 224, .62);

  --shadow:        0 6px 24px rgba(0, 0, 0, .45);
  --shadow-sm:     0 2px 8px rgba(0, 0, 0, .35);

  --scroll-thumb:  rgba(140, 160, 185, .30);
}

/* ==================== 2. RESET / BASE ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* PRIVACIDADE: nada selecionável/copiável. Exceto campos de digitação,
   onde o usuário PRECISA digitar (e colar o código de entrada). */
html, body { height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  /* Rolagem livre (pan-x pan-y) mas sem PINÇA-zoom: "manipulation"/auto
     incluem pinch-zoom; aqui removemos só o zoom, preservando o pan. */
  touch-action: pan-x pan-y;
  overflow: hidden;
}
input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.hidden { display: none !important; }
button:disabled { opacity: .5; pointer-events: none; }

/* ==================== 3. SPLASH ==================== */
.splash {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; background: var(--bg);
  transition: opacity .35s ease, visibility .35s;
}
.splash.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-brand {
  font-size: 30px; font-weight: 800; letter-spacing: -.5px;
  background: var(--primary-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 4. SHELL DO APP ==================== */
/* A altura do app é --app-h, definida pelo JS (visualViewport) em
   assets/js/app.js (initVisualViewport). Assim, no celular:
   - o topo (header) NUNCA rola para fora da tela quando o teclado abre
     (o documento passa a ter exatamente a altura visível);
   - o rodapé (campo de mensagem) fica colado acima do teclado, sem vão.
   Fallback sem JS: 100dvh. */
.app {
  height: var(--app-h, 100dvh);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.app-header {
  position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.hd-sec { display: flex; align-items: center; gap: 10px; width: 100%; }
#hdHome { justify-content: space-between; }
.hd-center { flex: 1; text-align: center; }
.hd-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.hd-right { display: flex; align-items: center; gap: 8px; }
/* Botão "Como funciona?" (home) — pequeno, visível mesmo no menor viewport */
.how-btn {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 6px 12px; border-radius: 16px;
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background .18s, transform .12s;
}
.how-btn:active { transform: scale(.95); background: var(--chat-bg); }
.hd-title { font-size: 15px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-subtitle { font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-badge {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 700;
  background: var(--primary-grad);
  box-shadow: var(--shadow-sm);
}

.app-main { position: relative; overflow: hidden; background: var(--chat-bg); }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ==================== 5. ÍCONES SVG (mask) ====================
   Padrão: .ico é um quadrado com máscara SVG (assets/icons/*.svg).
   A cor vem de background-color: currentColor; o SVG define apenas a FORMA
   (canal alfa da máscara) — um único arquivo por ícone serve a qualquer tema. */
.ico {
  display: inline-block;
  width: 20px; height: 20px;
  flex: 0 0 auto;
  background-color: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}

.ico-help     { --ico: url('../icons/help.svg'); }
.ico-door     { --ico: url('../icons/door.svg'); }
.ico-copy     { --ico: url('../icons/copy.svg'); }
.ico-lock     { --ico: url('../icons/lock.svg'); }
.ico-shield   { --ico: url('../icons/shield.svg'); }
.ico-smile    { --ico: url('../icons/smile.svg'); }
.ico-attach   { --ico: url('../icons/attach.svg'); }
.ico-mic      { --ico: url('../icons/mic.svg'); }
.ico-send     { --ico: url('../icons/send.svg'); }
.ico-x        { --ico: url('../icons/x.svg'); }
.ico-trash    { --ico: url('../icons/trash.svg'); }
.ico-play     { --ico: url('../icons/play.svg'); }
.ico-pause    { --ico: url('../icons/pause.svg'); }
.ico-download { --ico: url('../icons/download.svg'); }
.ico-down     { --ico: url('../icons/down.svg'); }
.ico-photo    { --ico: url('../icons/photo.svg'); }
.ico-video    { --ico: url('../icons/video.svg'); }
.ico-timer    { --ico: url('../icons/timer.svg'); }
.ico-money    { --ico: url('../icons/money.svg'); }

/* Tema claro → ícone de SOL (o clique leva ao escuro); escuro → LUA. */
.ico-theme { --ico: url('../icons/moon.svg'); }
html[data-theme="light"] .ico-theme { --ico: url('../icons/sun.svg'); }

/* ==================== 6. BANDEIRAS (SVG self-hosted) ==================== */
.flag {
  display: inline-block; width: 22px; height: 15px; border-radius: 3px;
  overflow: hidden; flex: 0 0 auto;
  background-color: #fff; background-repeat: no-repeat; background-position: center;
  background-size: 100% 100%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.flag-br { background-image: url('../flags/br.svg'); }
.flag-es { background-image: url('../flags/es.svg'); }
.flag-en { background-image: url('../flags/en.svg'); }

/* Seletor de idioma — menu suspenso (botão + lista) */
.lang-wrap { position: relative; }
.lang-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 18px;
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background .18s, transform .12s;
}
.lang-toggle .flag { width: 18px; height: 12px; }
.lang-toggle:active { transform: scale(.95); }
.lang-caret { width: 12px; height: 12px; opacity: .7; transition: transform .18s; }
.lang-wrap.open .lang-caret { transform: rotate(180deg); }
.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  min-width: 178px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  animation: pop-msg .16s ease;
}
.lang-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; border-radius: 10px;
  font-size: 13px; font-weight: 650; color: var(--text-soft);
  transition: background .15s, color .15s;
}
.lang-btn:hover { background: var(--surface-2); }
.lang-btn.active { background: var(--primary-grad); color: #fff; box-shadow: var(--shadow-sm); }
.lang-full { letter-spacing: .2px; }
.lang-name { letter-spacing: .3px; }

/* ==================== 7. HOME ==================== */
.view-home { align-items: center; justify-content: flex-start; overflow-y: auto; padding: 28px 20px 10px; background: var(--bg); }
.hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.brand { font-size: 38px; font-weight: 800; letter-spacing: -.6px; margin-top: 4px;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.tagline { font-size: 14.5px; color: var(--text-soft); max-width: 300px; line-height: 1.5; }

.home-actions { width: 100%; max-width: 420px; margin-top: 34px; display: flex; flex-direction: column; gap: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 20px; border-radius: 14px; font-weight: 650; font-size: 15px;
  transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn-lg { width: 100%; padding: 16px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger  { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--text-soft); border: 1px solid var(--border); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: 13px; margin: 18px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.join-box { margin-top: 14px; }
.join-label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 8px; text-align: center; }
.join-row { display: flex; gap: 9px; }
.join-input-wrap { position: relative; flex: 1; min-width: 0; }
.join-input {
  width: 100%; min-width: 0;
  padding: 14px 44px 14px 16px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--surface-2);
  font-size: 17px; font-weight: 700; letter-spacing: 5px; text-transform: uppercase;
  text-align: center; color: var(--text); outline: none; transition: border-color .2s;
}
.join-input:focus { border-color: var(--primary); background: var(--surface); }
.join-input::placeholder { letter-spacing: 6px; color: var(--text-faint); font-weight: 500; }

/* Botão pequeno "Colar" dentro do campo do código */
.paste-btn {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border); cursor: pointer;
  transition: color .15s, border-color .15s, transform .1s;
}
.paste-btn:hover { color: var(--primary); border-color: var(--primary); }
.paste-btn:active { transform: translateY(-50%) scale(.92); }
.paste-btn .ico { width: 15px; height: 15px; }

/* Acessível: texto só para leitores de tela */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.field-error { color: var(--danger); font-size: 12.5px; text-align: center; margin-top: 9px; }

.privacy-note {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 26px; color: var(--text-faint); font-size: 12px; text-align: center;
}

/* ==================== 7.1 MOBILE: CAMPO DE CÓDIGO "DESTACADO" ====================
   No celular, ao focar o campo de código (home > "Entrar com código"), o card
   salta à frente — fixo no alto, acima do teclado — e o restante da página
   fica desfocado atrás de um backdrop. Tocar fora (ou Esc) volta ao normal.
   Só vale até 720px de largura: no desktop o comportamento é o padrão. */
@media (max-width: 720px) {
  #codeBackdrop {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(15, 23, 42, .34);
    -webkit-backdrop-filter: blur(6px) saturate(.85);
    backdrop-filter: blur(6px) saturate(.85);
    opacity: 0; visibility: hidden;
    transition: opacity .22s ease, visibility .22s;
  }
  html.code-focus #codeBackdrop { opacity: 1; visibility: visible; }
  /* Sem suporte a backdrop-filter: só o escurecimento (nunca perde a função). */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    #codeBackdrop { background: rgba(8, 15, 30, .45); }
  }

  html.code-focus .join-box {
    position: fixed;
    left: 16px; right: 16px;
    top: calc(10vh + var(--safe-top));
    z-index: 50;
    margin-top: 0;
    padding: 18px 16px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    animation: codePop .26s cubic-bezier(.2, .9, .3, 1.15);
  }
  @keyframes codePop {
    from { transform: translateY(16px) scale(.94); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
  }
}

/* ==================== 8. AGUARDANDO ==================== */
.view-waiting { align-items: center; justify-content: center; padding: 24px; }
.waiting-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 30px 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 18px; align-items: center;
  animation: pop .35s cubic-bezier(.2,.9,.3,1.2);
}
.waiting-status { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--text-soft); font-weight: 550; }
.pulse-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--orange); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,159,28,.55);} 50% { box-shadow: 0 0 0 8px rgba(255,159,28,0);} }

.code-display {
  font-size: 40px; font-weight: 800; letter-spacing: 9px; text-align: center;
  color: var(--primary); font-variant-numeric: tabular-nums;
  padding: 14px 18px; border-radius: 16px; background: var(--surface-2);
  border: 1.5px dashed var(--border);
  min-width: 250px;
}
.waiting-hint { font-size: 13px; color: var(--text-faint); text-align: center; line-height: 1.5; max-width: 290px; }
.view-waiting .btn { width: 100%; }

/* ==================== 9. CHAT ==================== */
.view-chat { background: var(--chat-bg); }

.msg-list {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 12px 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  -webkit-overflow-scrolling: touch;
}

/* Tira o foco azul feio de UI Webkit ao tocar na lista */
.msg-list:focus { outline: none; }

/* Separador de data */
.day-divider {
  display: flex; align-items: center; justify-content: center; margin: 16px 0 10px;
}
.day-pill {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 11.5px; font-weight: 650;
  padding: 5px 13px; border-radius: 20px; box-shadow: var(--shadow-sm);
}

/* Bolhas */
.bubble-row { display: flex; margin: 3px 0; animation: pop-msg .28s cubic-bezier(.2,.9,.3,1.1); }
.bubble-row.out { justify-content: flex-end; }
.bubble-row.in  { justify-content: flex-start; }
.bubble {
  position: relative; max-width: min(80vw, 480px);
  padding: 8px 12px 6px; border-radius: var(--radius);
  font-size: 15px; line-height: 1.42;
  /* word-break: break-word vira "anywhere" no Chromium e QUEBRA clusters de
     emoji no meio (variação U+FE0F / ZWJ) quando a linha quebra. overflow-wrap
     quebra só em borda de palavra — emojis repetidos ficam intactos. */
  word-break: normal; overflow-wrap: break-word;
  box-shadow: var(--shadow-sm);
}
.bubble.out { background: var(--bubble-out); color: var(--bubble-out-tx); border-bottom-right-radius: 5px; }
.bubble.in  { background: var(--bubble-in); color: var(--bubble-in-tx); border-bottom-left-radius: 5px; }
.bubble .msg-time {
  display: block; text-align: right; font-size: 10.5px; margin-top: 2px;
  color: var(--bubble-time); letter-spacing: .2px;
}

/* Links clicáveis dentro das mensagens (abrem em nova janela, fora do app) */
.bubble a {
  text-decoration: underline; text-underline-offset: 2px; font-weight: 600;
  word-break: break-all;
}
.bubble.out a { color: #ffffff; }
.bubble.in a  { color: var(--primary); }
.bubble a:active { opacity: .75; }

/* Onda visível na bolha de voz (para quem envia e quem recebe; anima no play) */
.audio-wave {
  display: flex; align-items: center; gap: 2px;
  height: 30px; margin-bottom: 4px; padding: 0 2px;
}
.audio-wave span {
  flex: 1 1 0; min-width: 2px; height: var(--h);
  border-radius: 2px; transform-origin: center;
}
.audio-bubble.out .audio-wave span { background: rgba(255, 255, 255, .9); }
.audio-bubble.in  .audio-wave span { background: var(--primary-2); }
.audio-wave.playing span {
  animation: waveBounce .8s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.06s);
}
@keyframes waveBounce {
  0%, 100% { transform: scaleY(.5); }
  50%      { transform: scaleY(1); }
}
.audio-bubble {
  display: flex; align-items: center; gap: 10px; min-width: 210px; max-width: 260px;
  padding: 9px 12px;
}
.audio-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.22); color: inherit; transition: transform .15s;
}
.audio-btn:active { transform: scale(.9); }
.audio-info { flex: 1; min-width: 0; }
.audio-progress { height: 4px; border-radius: 3px; background: rgba(127,127,127,.3); overflow: hidden; }
.audio-progress > span { display: block; height: 100%; width: 0; background: currentColor; border-radius: 3px; transition: width .2s linear; }
.audio-meta { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; opacity: .85; font-variant-numeric: tabular-nums; }
/* "recebendo... X%" — linha compacta dentro da coluna de info, embaixo da
   onda/progresso: nunca sobrepõe o player (é fluxo normal da coluna). */
.audio-loading {
  font-size: 10.5px; opacity: .85;
  display: flex; align-items: center; gap: 5px;
  font-variant-numeric: tabular-nums; margin-top: 4px;
}
.audio-loading .ico { width: 12px; height: 12px; }
.audio-loading .percent { font-weight: 700; }

/* --- Bolha de mídia (foto/vídeo) sem miniatura, só info + baixar --- */
.media-bubble { min-width: 230px; max-width: 300px; }
.media-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.media-type-ico { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(127,127,127,.18); }
.media-name { font-size: 14px; font-weight: 650; word-break: break-all; }
.media-meta { font-size: 11.5px; opacity: .8; margin-top: 1px; }
.media-dl {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; border-radius: 11px; font-weight: 700; font-size: 13.5px;
  background: rgba(255,255,255,.18); color: inherit; margin-top: 4px;
  border: 1px solid rgba(255,255,255,.25);
  transition: background .2s, transform .12s;
}
.media-dl:active { transform: scale(.98); background: rgba(255,255,255,.28); }

/* --- Mensagens de sistema (centrais) --- */
.sys-msg {
  display: flex; justify-content: center; margin: 12px 0 4px;
}
.sys-pill {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 12.5px; padding: 7px 16px;
  border-radius: 20px; box-shadow: var(--shadow-sm); text-align: center;
  display: flex; align-items: center; gap: 8px;
}
.sys-pill .ico { width: 15px; height: 15px; }
.sys-pill.warn { color: var(--danger); border-color: rgba(229,72,77,.35); }

/* Indicador "digitando..." no cabeçalho (abaixo dos nomes) */
.hd-typing {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 650; color: var(--primary);
  margin-top: 1px; letter-spacing: .2px;
  animation: pop-msg .18s ease;
}
.hd-typing .typing-dots span { width: 5px; height: 5px; background: var(--primary); }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint);
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,60%,100% { opacity: .25; transform: translateY(0);} 30% { opacity: 1; transform: translateY(-3px);} }

/* Botão nova mensagem (flutuante) */
.new-msg-pill {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); color: var(--primary);
  border: 1px solid var(--border); border-radius: 24px;
  padding: 9px 16px; font-size: 13px; font-weight: 650;
  box-shadow: var(--shadow); z-index: 12; animation: pop .25s ease;
}
.new-msg-pill:active { transform: translateX(-50%) scale(.96); }

/* Banner de expiração (topo do chat) */
.expiry-banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--orange); color: #fff;
  font-size: 12.5px; font-weight: 650; padding: 8px 12px;
  animation: slideDown .3s ease;
  box-shadow: var(--shadow-sm);
}
html[data-theme="dark"] .expiry-banner { color: #1a1406; }
@keyframes slideDown { from { transform: translateY(-100%);} to { transform: translateY(0);} }

/* ==================== COMPOSER ==================== */
.composer-wrap {
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom); z-index: 15;
}
.composer {
  display: flex; align-items: flex-end; gap: 7px;
  padding: 8px 10px;
}
.input-shell { flex: 1; min-width: 0; }
.text-input {
  width: 100%; resize: none; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 15.5px; line-height: 1.45;
  color: var(--text); padding: 9px 13px; border-radius: 22px;
  background: var(--surface-2);
  max-height: 128px; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
.text-input::placeholder { color: var(--text-faint); }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--text-soft); transition: background .18s, color .18s, transform .12s;
}
.icon-btn:active { transform: scale(.88); background: var(--surface-2); }
.icon-btn.danger { color: var(--danger); }
.send-btn {
  background: var(--primary-grad); color: #fff;
  box-shadow: var(--shadow-sm);
}
.send-btn:active { transform: scale(.88); }
.send-btn .ico { margin-left: 2px; }

/* Botão redondo verde de DOAÇÃO (home + chat) — menor que os .icon-btn (32px) */
.donate-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green-grad); color: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .12s, filter .18s;
}
.donate-btn:active { transform: scale(.88); filter: brightness(1.08); }
.donate-btn .ico { width: 16px; height: 16px; }

.copy-btn {
  padding: 7px 13px; border-radius: 18px; font-size: 12.5px; font-weight: 700;
  background: var(--surface-2); color: var(--primary);
  border: 1px solid var(--border); transition: background .18s, transform .12s;
}
.copy-btn:active { transform: scale(.95); }
.danger-btn {
  padding: 7px 13px; border-radius: 18px; font-size: 12.5px; font-weight: 700;
  background: rgba(229,72,77,.12); color: var(--danger);
  border: 1px solid rgba(229,72,77,.3);
  transition: background .18s, transform .12s;
}
.danger-btn:active { transform: scale(.95); background: rgba(229,72,77,.2); }

/* ---- Painel de emojis ---- */
.emoji-panel {
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 38dvh; max-height: 320px;
}
.emoji-cats {
  display: flex; gap: 2px; padding: 6px 8px; overflow-x: auto;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  scrollbar-width: thin;
}
.emoji-cat {
  padding: 6px 11px; border-radius: 16px; font-size: 14px;
  color: var(--text-faint); white-space: nowrap; font-weight: 650;
}
.emoji-cat.active { background: var(--primary); color: #fff; }
.emoji-grid {
  flex: 1; overflow-y: auto; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 2px; padding: 8px;
  scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
.emoji-cell {
  font-size: 25px; line-height: 1; padding: 8px 4px;
  border-radius: 9px; text-align: center;
  transition: background .12s, transform .1s;
}
.emoji-cell:active { background: var(--surface-2); transform: scale(1.15); }

/* ---- Módulo de gravação ---- */
.composer-rec { align-items: center; padding: 8px 12px; background: var(--surface); }
.rec-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rec-canvas { width: 100%; max-width: 320px; height: 44px; }
.rec-timer {
  font-size: 12.5px; font-weight: 700; color: var(--danger);
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}
.rec-timer.overtime { animation: blinkGlow 0.6s infinite; }
@keyframes blinkGlow { 50% { opacity: .35; } }
.rec-red-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1.1s infinite; }

/* ==================== 10. MODAIS ==================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 20, 34, .55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px calc(18px + var(--safe-bottom)/2);
  animation: fadeIn .2s ease;
}
.modal {
  width: 100%; max-width: 440px; max-height: min(82dvh, 640px);
  background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  overflow: hidden; animation: pop .28s cubic-bezier(.2,.9,.3,1.15);
}
.modal-sm { max-width: 380px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
}
.modal-head h2 { font-size: 17px; font-weight: 750; }
/* Abas do modal informativo — arquitetura "ícone + rótulo" em grid:
   sempre 3 colunas iguais (alinhamento perfeito por construção, em qualquer
   largura), sem trilho e sem rolagem — o texto nunca é cortado e, se couber,
   quebra de linha centralizado abaixo do ícone. Altura mínima generosa para
   toque no celular. */
.modal-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 2px 16px 14px;
}
.modal-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 66px; padding: 8px 4px 10px;
  border-radius: 16px; color: var(--text-soft);
  transition: background .18s, color .18s, transform .12s;
}
.modal-tab:active { transform: scale(.97); }
.modal-tab .modal-tab-ico { width: 24px; height: 24px; opacity: .8; transition: opacity .18s; }
.modal-tab .modal-tab-label {
  font-size: 11px; font-weight: 700; line-height: 1.2; text-align: center;
  letter-spacing: .1px; white-space: normal;
}
.modal-tab.active { background: var(--surface-2); color: var(--primary); }
.modal-tab.active .modal-tab-ico { opacity: 1; }
.modal-body {
  flex: 1; min-height: 0;
  padding: 4px 18px 20px; overflow-y: auto; overscroll-behavior: contain;
  font-size: 14px; line-height: 1.6; color: var(--text-soft);
}
.modal-body p { margin-bottom: 10px; }
.modal-body strong { color: var(--text); }
.modal-body h3 { font-size: 13.5px; color: var(--text); margin: 14px 0 6px; font-weight: 700; }
.modal-body ul { padding-left: 18px; margin-bottom: 8px; }
.modal-body li { margin-bottom: 5px; }
.modal-body .accent { color: var(--primary); font-weight: 650; }

.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ---------- Doação (modal home/chat/fim) ---------- */
.donate-hero { display: flex; justify-content: center; margin: 8px 0 14px; }
.donate-hero-circle {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 185, 129, .14); color: var(--green);
}
.donate-hero-circle .ico { width: 28px; height: 28px; }
.donate-text { text-align: center; color: var(--text-soft); font-size: 14.5px; line-height: 1.65; }
.btn-donate { background: var(--green-grad); color: #fff; box-shadow: var(--shadow-sm); }
/* Fim de sala: botões empilhados (Voltar para home acima, Fazer Doação abaixo) */
.modal-actions-stack { flex-direction: column; }

/* ---------- Modal informativo ("Como funciona") ----------
   Celular: bottom sheet moderno (encaixa na base, cantos superiores
   arredondados, safe-area respeitada). Desktop (≥600px): diálogo central. */
.modal-backdrop.info-sheet { align-items: flex-end; padding: 0; }
.modal-backdrop.info-sheet .modal {
  position: relative;
  width: 100%; max-width: 100%;
  max-height: min(88dvh, 720px);
  border-radius: 24px 24px 0 0;
  animation: sheetUp .32s cubic-bezier(.2, .9, .3, 1.05);
}
.modal-backdrop.info-sheet .modal-body { padding: 4px 20px calc(24px + var(--safe-bottom)); }
/* Cabeçalho do sheet: título centralizado (simétrico) com o X ancorado à direita */
.modal-backdrop.info-sheet .modal-head {
  justify-content: center;
  padding: 22px 52px 10px;
}
.modal-backdrop.info-sheet .modal-head h2 { font-size: 16px; letter-spacing: .2px; }
.modal-backdrop.info-sheet #modalClose { position: absolute; top: 12px; right: 12px; }
/* Transição suave ao trocar de aba */
.modal-body--info.sheet-switch { animation: fadeUp .22s ease; }
/* Alça de arraste ("grip") do bottom sheet: visual + área para dispensar arrastando */
.modal-backdrop.info-sheet .modal::before {
  content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px; border-radius: 2px; background: var(--border);
  pointer-events: none; z-index: 2;
}
@keyframes sheetUp {
  from { transform: translateY(28px); opacity: .35; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Conteúdo: texto justificado (com hifenização para caber no celular),
   hierarquia limpa — barrinha no título, marcadores de bolinha. */
.modal-body--info {
  text-align: justify; -webkit-hyphens: auto; hyphens: auto;
  font-size: 14.5px; line-height: 1.75;
}
.modal-body--info p { margin-bottom: 10px; }
.modal-body--info h3 {
  font-size: 13.5px; color: var(--text); margin: 20px 0 8px; font-weight: 750;
  display: flex; align-items: center; gap: 8px;
}
.modal-body--info h3::before {
  content: ''; flex: 0 0 auto; width: 3px; height: 14px; border-radius: 2px;
  background: var(--primary-grad);
}
.modal-body--info ul { list-style: none; padding: 0; margin: 0 0 10px; }
.modal-body--info li { position: relative; padding-left: 16px; margin-bottom: 6px; }
.modal-body--info li::before {
  content: ''; position: absolute; left: 2px; top: .68em;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--primary); opacity: .85;
}
.modal-body--info .accent {
  display: block; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--primary); font-weight: 700; text-align: center;
}

/* ---------- Progresso ---------- */
.progress-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 14px; text-align: center; }
.progress-bar {
  height: 10px; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--border); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 8px;
  background: var(--primary-grad); transition: width .18s ease;
}
.progress-pct { text-align: center; font-size: 13px; font-weight: 700; color: var(--primary); margin-top: 9px; font-variant-numeric: tabular-nums; }
.progress-actions { display: flex; justify-content: center; margin-top: 16px; }

/* ---------- Anexo ---------- */
.attach-option {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 15px; border-radius: 14px; text-align: left;
  border: 1px solid var(--border); background: var(--surface-2);
  margin-bottom: 10px; transition: background .18s, transform .12s;
}
.attach-option:active { transform: scale(.98); background: var(--chat-bg); }
.attach-ico {
  width: 46px; height: 46px; border-radius: 14px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  -webkit-mask-size: 24px; mask-size: 24px;
}
.attach-option:first-child .attach-ico { background: linear-gradient(135deg,#0a7de1,#5db2ff); }
.attach-option:last-child  .attach-ico { background: linear-gradient(135deg,#f0703a,#ff9f1c); }
.attach-name { font-size: 15px; font-weight: 700; color: var(--text); }
.attach-desc { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* Toast (micro avisos) */
.toast-zone {
  position: fixed; left: 50%; bottom: 105px; transform: translateX(-50%);
  z-index: 250; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: rgba(16, 26, 40, .92); color: #fff;
  font-size: 12.5px; padding: 9px 16px; border-radius: 22px;
  box-shadow: var(--shadow); animation: toastIn .25s ease;
  text-align: center; max-width: 90vw;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px);} to { opacity: 1; transform: none; } }

/* ==================== 11. SCROLLBARS (minimalistas) ==================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) var(--scroll-track); }

/* ==================== 12. ANIMAÇÕES ==================== */
@keyframes pop { from { opacity: 0; transform: scale(.92);} to { opacity: 1; transform: scale(1);} }
@keyframes pop-msg { from { opacity: 0; transform: translateY(8px) scale(.97);} to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0;} to { opacity: 1; } }

/* ==================== 13. DESKTOP ==================== */
/* Modal informativo: no desktop volta a ser um diálogo centralizado */
@media (min-width: 600px) {
  .modal-backdrop.info-sheet { align-items: center; padding: 18px calc(18px + var(--safe-bottom)/2); }
  .modal-backdrop.info-sheet .modal {
    max-width: 440px; max-height: min(82dvh, 640px);
    border-radius: 20px;
    animation: pop .28s cubic-bezier(.2, .9, .3, 1.15);
  }
  .modal-backdrop.info-sheet .modal-body { padding: 4px 18px 20px; }
  /* diálogo centralizado não precisa da alça de arraste */
  .modal-backdrop.info-sheet .modal::before { display: none; }
}
@media (min-width: 900px) {
  .app { max-width: 720px; margin: 0 auto; box-shadow: 0 0 60px rgba(10,30,60,.12); }
  body { background: var(--bg-soft); }
  .bubble { max-width: 480px; }
  .msg-list { padding: 20px 26px; }
}