/* ==========================================================================
   Glória Conecta — identidade da Paróquia Nossa Senhora da Glória
   Azul mariano profundo, creme, dourado e composição editorial.

   Consolidado: no protótipo havia uma camada base sobrescrita por outra
   camada inteira. Aqui os valores finais estão em um lugar só.
   ========================================================================== */

:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --panel-2: #f8f6f2;
  --text: #2c3032;
  --muted: #74797c;
  --line: #e1ddd5;
  --primary: #286181;
  --primary-2: #072b4b;
  --accent: #b89552;
  --accent-soft: #f6efdf;
  --success: #49775f;
  --danger: #a64b4b;
  --shadow: 0 8px 26px rgba(25, 43, 55, .07);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Arial, Helvetica, sans-serif;

  /* Respeita a área segura de celulares com notch */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); color: var(--primary-2); }

img, video { max-width: 100%; }

/* Foco visível para quem navega por teclado */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Tela de acesso
   ========================================================================== */

body.auth-locked { overflow: hidden; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background:
    linear-gradient(135deg, rgba(7,43,75,.97), rgba(40,97,129,.92)),
    var(--primary-2);
}

.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  background-image:
    radial-gradient(circle at 20% 25%, white 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 34%, white 0 1px, transparent 1.5px),
    radial-gradient(circle at 45% 78%, white 0 1px, transparent 1.5px);
  background-size: 96px 96px, 132px 132px, 112px 112px;
}

.login-screen.hidden { display: none; }

.login-card {
  position: relative;
  width: min(100%, 440px);
  margin: auto;
  padding: 30px;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(255,255,255,.5);
  border-top: 4px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 30px 80px rgba(0,0,0,.24);
}

.login-logo {
  display: block;
  width: min(100%, 300px);
  height: auto;
  margin: 0 auto 22px;
}

.login-card h1 { font-size: 33px; letter-spacing: -.02em; margin: 0 0 8px; }
.login-card > p { color: var(--muted); line-height: 1.6; margin-bottom: 22px; font-size: 14px; }

.login-fields { display: grid; gap: 11px; }
.login-label {
  display: grid;
  gap: 6px;
  color: var(--primary-2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-submit { width: 100%; margin-top: 15px; padding: 13px 16px; }
.login-label .opcional { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); }

/* Alternador entre entrar e criar cadastro */
.alternador {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 20px;
  padding: 4px;
  background: #efece6;
  border-radius: 4px;
}
.alternador-btn {
  border: 0;
  background: transparent;
  border-radius: 3px;
  padding: 11px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  min-height: 44px;
  transition: background .15s ease, color .15s ease;
}
.alternador-btn.active {
  background: #fff;
  color: var(--primary-2);
  box-shadow: 0 1px 4px rgba(25,43,55,.12);
}
.alternador-btn:not(.active):hover { color: var(--primary-2); }

.campo-cadastro[hidden] { display: none; }

.login-note {
  margin-top: 15px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}
.login-note a { color: var(--primary); }

/* Entrar com Google */
.google-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid #d4cec4;
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}
.google-btn:hover { background: #faf9f6; }
.google-btn svg { width: 18px; height: 18px; flex: none; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Tela de espera pela liberação do cadastro */
.espera-conta {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-size: 14px;
  line-height: 1.5;
  color: #5c4a1e;
}
.espera-conta strong { display: block; color: var(--primary-2); }
.espera-conta.recusado { border-left-color: var(--danger); background: #fbeeee; color: #7b2f2f; }
.espera-conta.recusado strong { color: #7b2f2f; }

.login-feedback {
  margin-top: 14px;
  padding: 11px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #5c4a1e;
  font-size: 12px;
  line-height: 1.55;
}
.login-feedback[hidden] { display: none; }
.login-feedback.erro { border-left-color: var(--danger); background: #fbeeee; color: #7b2f2f; }
.login-feedback a { color: var(--primary-2); word-break: break-all; }

/* ==========================================================================
   Cabeçalho
   ========================================================================== */

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-top: 5px solid var(--primary-2);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.98);
  box-shadow: 0 4px 18px rgba(22,38,50,.045);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent 6%, var(--accent) 32%, var(--accent) 68%, transparent 94%);
  opacity: .75;
}

.topbar-inner {
  max-width: 1220px;
  min-height: 76px;
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Emblema da paróquia no cabeçalho */
.brand-mark {
  width: auto;
  height: 46px;
  flex: none;
  object-fit: contain;
}

.brand-title { color: var(--primary-2); font-family: var(--serif); font-size: 20px; line-height: 1.05; }
.brand-subtitle {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-top: 4px;
}

.topbar-actions { display: flex; align-items: center; gap: 18px; }

.main-nav { display: flex; gap: 0; }
.nav-btn {
  position: relative;
  border: 0;
  background: transparent;
  color: #555b60;
  font-weight: 700;
  padding: 12px 15px;
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.nav-btn.active { color: var(--primary-2); }
.nav-btn::after {
  content: "";
  position: absolute;
  left: 15px; right: 15px; bottom: 4px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .18s ease;
}
.nav-btn.active::after { transform: scaleX(1); }
.nav-btn .badge {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  margin-left: 5px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 1px solid var(--line);
  padding: 4px 0 4px 16px;
}
.user-chip-avatar {
  width: 28px; height: 28px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--accent);
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}
.user-chip-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-2);
}
.logout-btn {
  border: 0;
  padding: 6px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.logout-btn:hover { color: var(--danger); }

/* ==========================================================================
   Estrutura
   ========================================================================== */

main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 36px 24px calc(60px + var(--safe-bottom));
}

.view { display: none; }
.view.active { display: block; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
  padding: 7px 0 22px 22px;
  border-bottom: 1px solid var(--line);
}
.hero::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 22px;
  width: 3px;
  background: var(--accent);
}
.hero p { color: var(--muted); max-width: 760px; margin-bottom: 0; font-size: 13px; line-height: 1.6; }

.eyebrow {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  font-weight: 800;
}

h1 { margin: 7px 0 9px; font-size: clamp(34px, 5vw, 52px); letter-spacing: -.025em; line-height: 1; }

.period-badge {
  padding: 9px 0 8px 20px;
  border-left: 1px solid var(--line);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.panel {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.footer-note { text-align: center; color: var(--muted); font-size: 11px; margin-top: 22px; line-height: 1.7; }
.footer-note a { color: var(--primary); }

/* ==========================================================================
   Botões
   ========================================================================== */

.back-btn, .ghost-btn, .primary-btn, .danger-btn {
  border: 0;
  border-radius: 3px;
  font-weight: 800;
  padding: 10px 14px;
}
.back-btn, .ghost-btn { border: 1px solid #d5cfc4; background: #fff; color: var(--primary-2); }
.back-btn:hover, .ghost-btn:hover { background: var(--panel-2); }
.primary-btn { background: var(--primary-2); color: #fff; }
.primary-btn:hover { background: var(--primary); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.danger-btn { background: #fbeeee; color: var(--danger); }
.danger-btn:hover { background: #f7e2e2; }

.field, textarea, select.field {
  width: 100%;
  border: 1px solid #d4cec4;
  background: #fff;
  border-radius: 3px;
  padding: 12px 13px;
  outline: none;
  color: var(--text);
  /* 16px evita o zoom automático do iOS ao focar um campo */
  font-size: 16px;
  min-height: 46px;
}
.field:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(40,97,129,.12); }
textarea { min-height: 120px; resize: vertical; font-family: inherit; line-height: 1.55; }

/* ==========================================================================
   Calendário
   ========================================================================== */

.calendar-panel { overflow: hidden; }

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  background: var(--primary-2);
  border-bottom: 3px solid var(--accent);
}
.calendar-head h2 { color: #fff; font-size: 22px; margin: 0; }
.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: rgba(255,255,255,.72); font-size: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.dot.locked { background: rgba(255,255,255,.34); }

.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); }

.weekday {
  padding: 12px 8px;
  text-align: center;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
  color: #696d70;
  background: #efede8;
  border-bottom: 1px solid var(--line);
}

.day-cell {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  min-height: 116px;
  padding: 12px;
  text-align: left;
  position: relative;
  transition: .18s ease;
  color: inherit;
}
.day-cell:nth-child(7n) { border-right: 0; }
.day-cell.empty { background: #faf9f6; cursor: default; }
.day-cell.editable:hover { background: #fbfaf6; box-shadow: inset 0 0 0 2px rgba(184,149,82,.45); z-index: 2; }
.day-cell.locked { background: #f6f5f2; color: #a4a19c; cursor: not-allowed; }
.day-cell.today::before {
  content: "Hoje";
  position: absolute;
  top: 11px;
  right: 11px;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  font-size: 10px;
  font-weight: 900;
  padding: 2px 0;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.day-number { font-weight: 900; font-size: 20px; color: var(--primary-2); font-family: var(--serif); }
.locked .day-number { color: #999; }
.day-label { margin-top: 22px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.editable .day-label { color: var(--primary); font-weight: 700; }

.day-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mini-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  background: #faf9f6;
  border: 1px solid var(--line);
  padding: 3px 6px;
  font-size: 10px;
  border-radius: 2px;
}
.day-destaque {
  margin-top: 8px;
  color: var(--primary);
  font-size: 10px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Fórum
   ========================================================================== */

.forum-layout { max-width: 1090px; margin: 0 auto; }
.forum-main { min-width: 0; }

.forum-header {
  margin-bottom: 14px;
  border-radius: 4px;
  border-top: 3px solid var(--accent);
  box-shadow: none;
  padding: 0;
  overflow: hidden;
}
.forum-topline { display: flex; align-items: center; gap: 12px; padding: 17px 18px 14px; }
.forum-date { flex: 1; min-width: 0; }
.forum-date h2 { margin: 0 0 4px; font-size: 25px; }
.forum-date p { margin: 0; color: var(--muted); font-size: 12px; }
.forum-breadcrumb {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.subtabs { display: flex; gap: 2px; background: #efede8; border-top: 1px solid var(--line); padding: 0 18px; }
.subtab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 13px 10px;
  font-weight: 800;
  font-size: 9px;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.subtab.active { color: var(--primary-2); border-bottom-color: var(--accent); }

.thread-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eeeae2;
  color: var(--muted);
  font-size: 13px;
}
.thread-toolbar strong { color: var(--text); }
.reply-jump {
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: #fff;
  color: var(--primary-2);
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 700;
  min-height: 40px;
}
.reply-jump:hover { background: var(--accent-soft); }

/* ==========================================================================
   Conversa
   ==========================================================================
   Reconstruída para leitura, não para imitar fórum antigo. O público é da
   paróquia, boa parte com mais idade, quase todo acesso pelo celular — então
   texto grande, contraste alto, alvo de toque generoso e pouca moldura.
   ========================================================================== */

.conversa { display: flex; flex-direction: column; gap: 4px; }

/* --- Grupo: mensagem raiz + suas respostas --- */
.fio {
  background: #fff;
  border: 1px solid #ddd7cc;
  border-radius: 5px;
  overflow: hidden;
}
.fio + .fio { margin-top: 10px; }

/* --- Mensagem --- */
.msg {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  padding: 16px 18px;
  scroll-margin-top: 96px;
  position: relative;
}
.msg.flash { animation: flash 1.9s ease; }
@keyframes flash {
  0%, 100% { background: transparent; }
  30%      { background: #fbf3df; }
}

/* Respostas: recuadas, com um fio ligando à mensagem de origem */
.msg.resposta {
  padding-top: 13px;
  padding-bottom: 13px;
  padding-left: 30px;
  border-top: 1px solid #f0ece3;
  background: #fcfbf8;
}
.msg.resposta::before {
  content: "";
  position: absolute;
  left: 30px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e4ded2;
}
.msg.resposta:last-child::before { bottom: 50%; }

.msg-avatar {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: 2px solid #fff;
  outline: 1px solid rgba(184,149,82,.55);
  object-fit: cover;
}
.msg.resposta .msg-avatar { width: 36px; height: 36px; font-size: 14px; }

.msg-corpo { min-width: 0; }

/* --- Cabeçalho da mensagem --- */
.msg-cab {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-autor {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary-2);
  line-height: 1.3;
}
.msg-selo {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #7a6224;
  background: var(--accent-soft);
  border: 1px solid #e4d5b4;
  border-radius: 3px;
  padding: 2px 6px;
}
.msg-cat {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #eef3f6;
  border-radius: 3px;
  padding: 2px 7px;
}
.msg-hora { font-size: 13px; color: var(--muted); }
.msg-num { font-size: 12px; color: #a8a49c; margin-left: auto; }

/* --- Texto --- */
.msg-texto {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.62;
  color: #2f3335;
  /* Linha de leitura confortável, mesmo em tela larga */
  max-width: 68ch;
}
.msg.resposta .msg-texto { font-size: 15px; }

/* --- Referência a outra mensagem --- */
.msg-refer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 0 0 8px;
  padding: 6px 10px;
  border: 0;
  border-left: 3px solid var(--accent);
  background: #f7f4ed;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  border-radius: 0 3px 3px 0;
}
button.msg-refer { cursor: pointer; }
button.msg-refer:hover { background: #f2ede1; color: var(--primary-2); }
.msg-refer strong { color: var(--primary-2); font-weight: 700; }

/* --- Ações --- */
.msg-acoes {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  margin-left: -8px;
}
.msg-acao {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* 44px de altura: alvo de toque confortável no celular */
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #5f666a;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.msg-acao:hover { background: #f2efe8; color: var(--primary-2); }
.msg-acao.curtido { color: var(--primary); font-weight: 700; }
.msg-acao.curtido .icone { transform: scale(1.12); }
.msg-acao .icone { transition: transform .18s ease; }
.msg-acao .contagem {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef3f6;
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 700;
}
.msg-acao.curtido .contagem { background: #dce9f0; }
.msg-acao--fim { margin-left: auto; }

/* Ação de moderação: visível, mas sem competir com curtir e responder */
.msg-acao.moderar { color: var(--danger); }
.msg-acao.moderar:hover { background: #fbeeee; color: #7b2f2f; }

.msg-menu-btn {
  border: 0;
  background: transparent;
  color: #a8a49c;
  min-height: 40px;
  min-width: 40px;
  border-radius: 6px;
  font-size: 17px;
  line-height: 1;
}
.msg-menu-btn:hover { background: #f2efe8; color: var(--primary-2); }

/* Menu de excluir/denunciar */
.msg-menu {
  position: absolute;
  right: 14px;
  z-index: 12;
  min-width: 190px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 14px 38px rgba(25,43,55,.18);
}
.msg-menu[hidden] { display: none; }
.msg-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 11px 12px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--text);
}
.msg-menu button:hover { background: var(--panel-2); }
.msg-menu button.perigo { color: var(--danger); }
.msg-menu button.perigo:hover { background: #fbeeee; }

/* --- Mídia da mensagem --- */
.msg-midia {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  max-width: 560px;
  border-radius: 6px;
  overflow: hidden;
}
.msg-midia.n1 { grid-template-columns: 1fr; }
.msg-midia.n2 { grid-template-columns: 1fr 1fr; }
.msg-midia.n3, .msg-midia.n4 { grid-template-columns: 1fr 1fr; }
.msg-midia.n3 > :first-child { grid-column: 1 / -1; }

.midia-item {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: #10141a;
  overflow: hidden;
  cursor: zoom-in;
  line-height: 0;
}
.msg-midia.n1 .midia-item { aspect-ratio: auto; max-height: 460px; }
.msg-midia.n1 .midia-item img,
.msg-midia.n1 .midia-item video { max-height: 460px; object-fit: contain; }
.msg-midia:not(.n1) .midia-item { aspect-ratio: 1 / 1; }
.msg-midia:not(.n1) .midia-item img,
.msg-midia:not(.n1) .midia-item video { height: 100%; object-fit: cover; }
.midia-item img, .midia-item video { width: 100%; display: block; }

/* Vídeo cuja capa não pôde ser gerada */
.sem-capa {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 180px;
  height: 100%;
  font-size: 40px;
  background: linear-gradient(160deg, #123a5c, #071f36);
}
.media-thumb.sem-capa { aspect-ratio: 4 / 3; min-height: 0; font-size: 30px; }

/* Sinalização de vídeo: botão de play e duração */
.midia-item .play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.midia-item .play::before {
  content: "";
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(7,43,75,.72);
  backdrop-filter: blur(2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.midia-item .play::after {
  content: "";
  position: absolute;
  border-style: solid;
  border-width: 10px 0 10px 17px;
  border-color: transparent transparent transparent #fff;
  margin-left: 5px;
}
.midia-item .duracao {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(10,14,20,.78);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.midia-item .contador-extra {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(7,43,75,.62);
  color: #fff;
  font-family: var(--serif);
  font-size: 26px;
}

/* Aviso flutuante de mensagens novas chegando por tempo real */
.novas-msgs {
  position: sticky;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 20;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--primary-2);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(7,43,75,.35);
  animation: sobe .25s ease;
}
.novas-msgs[hidden] { display: none; }
@keyframes sobe { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Compositor
   ========================================================================== */

.composer { padding: 0; margin-top: 14px; overflow: hidden; border-radius: 3px; box-shadow: none; }
.composer-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  background: var(--primary-2);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.composer-body { padding: 14px; }
.composer-identity { color: rgba(255,255,255,.72); font-size: 11px; text-transform: none; letter-spacing: 0; }
.composer-identity strong { color: #fff; }

.composer-context {
  margin-bottom: 11px;
  padding: 10px 11px;
  border: 0;
  border-left: 3px solid var(--accent);
  background: #f7f4ed;
  color: var(--muted);
  font-size: 11px;
}
.composer-context[hidden] { display: none; }
.composer-context-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-context-head strong { color: var(--primary-2); }
.composer-context-cancel { border: 0; background: transparent; color: var(--danger); font-size: 10px; font-weight: 900; padding: 3px 5px; }

.composer-grid { display: grid; grid-template-columns: minmax(180px, 240px); gap: 12px; margin-bottom: 10px; }

.composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 10px;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: #f7f5f0;
  border: 1px solid #e0e4ed;
  border-radius: 2px;
  font-weight: 800;
  color: var(--primary-2);
  cursor: pointer;
}
.file-btn input { display: none; }
.file-note { color: var(--muted); font-size: 10px; margin-top: 4px; max-width: 380px; line-height: 1.5; }

.file-preview-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-pill {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-soft);
  border: 1px solid #f1dfaa;
  color: #725b20;
  border-radius: 2px;
  padding: 6px 9px;
  font-size: 11px;
}
.file-pill.enviando { opacity: .65; }
.file-pill.erro { background: #fbeeee; border-color: #e8c9c9; color: #7b2f2f; }
.file-pill img {
  width: 26px; height: 26px;
  object-fit: cover;
  border-radius: 2px;
  flex: none;
}
.file-pill button { border: 0; background: transparent; color: inherit; font-weight: 900; padding: 0 2px; }
.file-pill-nome { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Galeria
   ========================================================================== */

.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }

.media-card {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0;
  background: #fff;
  overflow: hidden;
  text-align: left;
  transition: .18s ease;
  min-width: 0;
}
.media-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(35,43,85,.12); }
.media-thumb {
  aspect-ratio: 4 / 3;
  width: 100%;
  display: block;
  object-fit: cover;
  background: #151515;
}
.media-card-video { position: relative; }
.media-card-video::after {
  content: "▶";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 26px;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
  pointer-events: none;
}
.media-card-info { padding: 10px 11px; border-top: 2px solid var(--accent); }
.media-card-title { font-weight: 800; font-size: 12px; color: var(--primary-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-meta { margin-top: 4px; font-size: 10px; color: var(--muted); }

.global-media-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}
.global-media-head h2 { margin-bottom: 5px; font-size: 32px; }
.global-media-head p { color: var(--muted); margin: 0; font-size: 13px; }

/* ==========================================================================
   Programação
   ========================================================================== */

.programacao { display: grid; gap: 8px; }

.programacao-item {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 3px;
  background: #fff;
}
.programacao-item.destaque { border-left-color: var(--accent); background: #fdfcf8; }
.programacao-hora {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-2);
  line-height: 1.2;
}
.programacao-fim { display: block; color: var(--muted); font-size: 10px; font-weight: 400; margin-top: 2px; }
.programacao-titulo { font-weight: 800; font-size: 14px; color: var(--primary-2); }
.programacao-desc { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.programacao-local {
  margin-top: 6px;
  display: inline-block;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.programacao-acoes { display: flex; gap: 6px; margin-top: 8px; }

.destaque-do-dia {
  margin-bottom: 14px;
  padding: 13px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #5c4a1e;
  font-size: 12px;
  line-height: 1.6;
}
.destaque-do-dia strong { color: var(--primary-2); }

/* ==========================================================================
   Modais
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background: rgba(7,43,75,.55);
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  position: relative;
  width: min(100%, 540px);
  margin: auto;
  background: #fff;
  border-top: 4px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}
.modal.largo { width: min(100%, 900px); }

.modal-head { padding: 22px 24px 0; }
.modal-head h2 { margin: 0 0 6px; font-size: 23px; }
.modal-head p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0; }

.modal-body { padding: 18px 24px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 16px 24px calc(20px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.termos-texto {
  max-height: 260px;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 12px;
  line-height: 1.7;
  color: #4a4f52;
}
.termos-texto h3 { font-size: 13px; margin: 14px 0 5px; color: var(--primary-2); }
.termos-texto h3:first-child { margin-top: 0; }
.termos-texto ul { margin: 6px 0; padding-left: 18px; }
.termos-texto li { margin-bottom: 4px; }

.check-linha {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.55;
  cursor: pointer;
}
.check-linha input { width: 18px; height: 18px; flex: none; margin-top: 1px; accent-color: var(--primary-2); }

/* Escolha da foto de perfil */
.foto-escolha { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.foto-previa {
  width: 108px;
  height: 108px;
  flex: none;
  border-radius: 50%;
  background: #eeeae2 center/cover no-repeat;
  border: 3px solid #fff;
  outline: 1px solid var(--accent);
  display: grid;
  place-items: center;
  font-size: 34px;
  color: #b4aea3;
}
.foto-previa:not(.tem-foto)::after { content: "👤"; }

.campo-linha { display: grid; gap: 6px; margin-bottom: 13px; }
.campo-linha > span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--primary-2);
}

/* Visualizador de mídia */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10,12,18,.94);
}
.lightbox[hidden] { display: none; }
.lightbox img, .lightbox video {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 3px;
}
.lightbox-fechar {
  position: absolute;
  top: 16px;
  right: 16px;
  border: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 20px;
}
.lightbox-info {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(18px + var(--safe-bottom));
  text-align: center;
  color: rgba(255,255,255,.85);
  font-size: 13px;
  padding: 0 20px;
}
.lightbox-legenda { margin-bottom: 10px; }

.lightbox-acoes {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.lightbox-acao {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  backdrop-filter: blur(3px);
}
.lightbox-acao:hover { background: rgba(255,255,255,.24); }
.lightbox-acao.sutil {
  background: transparent;
  font-weight: 500;
  color: rgba(255,255,255,.7);
}
.lightbox-acao.sutil:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ==========================================================================
   Painel de administração
   ========================================================================== */

.admin-abas { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.admin-aba {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 11px 14px;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.admin-aba.active { color: var(--primary-2); border-bottom-color: var(--accent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { padding: 16px; border: 1px solid var(--line); border-top: 3px solid var(--accent); background: #fff; border-radius: 3px; }
.stat-valor { font-family: var(--serif); font-size: 30px; color: var(--primary-2); line-height: 1; }
.stat-rotulo { margin-top: 6px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
.stat-card.alerta { border-top-color: var(--danger); }
.stat-card.alerta .stat-valor { color: var(--danger); }

.lista-admin { display: grid; gap: 10px; }
.item-admin {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}
.item-admin-topo { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.item-admin-meta { color: var(--muted); font-size: 11px; line-height: 1.6; }
.item-admin-conteudo {
  padding: 10px 12px;
  border-left: 3px solid var(--line);
  background: var(--panel-2);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.item-admin-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.item-admin img.previa { max-width: 200px; border-radius: 3px; border: 1px solid var(--line); }

.tabela-admin { width: 100%; border-collapse: collapse; font-size: 12px; }
.tabela-admin th, .tabela-admin td { padding: 10px; text-align: left; border-bottom: 1px solid var(--line); }
.tabela-admin th { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tabela-admin tr:hover td { background: var(--panel-2); }
.rolagem-x { overflow-x: auto; }

.etiqueta {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 2px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.etiqueta.ok { background: #e8f0ea; color: var(--success); }
.etiqueta.alerta { background: #fbeeee; color: var(--danger); }
.etiqueta.neutra { background: var(--accent-soft); color: #6b5722; }

/* ==========================================================================
   Estados e avisos
   ========================================================================== */

.empty-state {
  padding: 34px 22px;
  text-align: center;
  border: 1px dashed #ccd2e2;
  border-radius: 3px;
  color: var(--muted);
  background: rgba(255,255,255,.6);
  line-height: 1.6;
}
.empty-icon { font-size: 28px; margin-bottom: 10px; }
.empty-state strong { display: block; color: var(--primary-2); font-family: var(--serif); margin-bottom: 5px; font-size: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  background: var(--primary-2);
  color: #fff;
  padding: 11px 15px;
  border-radius: 2px;
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 14px 35px rgba(0,0,0,.22);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 190;
  font-size: 13px;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.erro { background: #7b2f2f; }

/* Esqueleto de carregamento */
.skeleton { display: grid; gap: 10px; }
.skeleton-linha {
  height: 92px;
  border-radius: 3px;
  background: linear-gradient(90deg, #efedE8 25%, #f7f6f3 50%, #efede8 75%);
  background-size: 200% 100%;
  animation: brilho 1.3s ease-in-out infinite;
}
@keyframes brilho { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Aviso de conexão perdida */
.conexao-aviso {
  position: fixed;
  left: 50%;
  top: 0;
  transform: translate(-50%, -100%);
  z-index: 195;
  padding: 8px 16px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 0 0 3px 3px;
  transition: transform .25s ease;
}
.conexao-aviso.show { transform: translate(-50%, 0); }

/* Convite para instalar o app */
.instalar-faixa {
  display: none;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 13px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #5c4a1e;
  font-size: 12px;
  line-height: 1.55;
}
.instalar-faixa.show { display: flex; }
.instalar-faixa strong { color: var(--primary-2); }

.carregar-mais { display: grid; place-items: center; margin-top: 16px; }

/* ==========================================================================
   Responsivo
   ========================================================================== */

@media (max-width: 900px) {
  .media-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .day-cell { min-height: 96px; padding: 9px; }
  .day-label, .day-destaque { display: none; }
}

@media (max-width: 650px) {
  .topbar { position: relative; }
  .topbar-inner { align-items: flex-start; flex-direction: column; padding: 13px 16px; gap: 12px; }
  .topbar-actions { width: 100%; align-items: stretch; flex-direction: column; gap: 0; }
  .main-nav { width: 100%; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .nav-btn { flex: 1; padding: 13px 8px; }
  .user-chip { justify-content: space-between; border-left: 0; padding: 10px 0 0; }
  .user-chip-name { max-width: none; }

  main { padding: 22px 14px calc(45px + var(--safe-bottom)); }
  .login-card { padding: 24px 20px; }

  .hero { grid-template-columns: 1fr; align-items: start; padding-left: 17px; }
  .period-badge { justify-self: start; padding: 8px 0 0; border-left: 0; border-top: 1px solid var(--line); }

  .calendar-head { align-items: flex-start; flex-direction: column; }
  .weekday { font-size: 9px; padding-inline: 2px; }
  .day-cell { min-height: 72px; padding: 8px 7px; }
  .day-number { font-size: 15px; }
  .day-stats { gap: 4px; margin-top: 6px; }
  .mini-stat { font-size: 9px; padding: 2px 4px; }
  .day-cell.today::before {
    content: "";
    width: 6px; height: 6px;
    padding: 0;
    top: 7px; right: 7px;
    background: var(--accent);
    border: 0;
    border-radius: 50%;
  }

  .composer-grid { grid-template-columns: 1fr; }
  .composer-actions { align-items: stretch; flex-direction: column; }
  .composer-actions .primary-btn { width: 100%; padding: 13px; }
  .file-btn { justify-content: center; }
  .file-note { max-width: none; }

  .forum-topline { align-items: flex-start; }
  .forum-date h2 { font-size: 19px; }
  .media-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }

  /* Conversa no celular: menos moldura lateral, mais espaço para o texto */
  .msg { padding: 14px 13px; gap: 10px; }
  .msg-avatar { width: 40px; height: 40px; font-size: 15px; }
  .msg.resposta { padding-left: 20px; }
  .msg.resposta::before { left: 20px; }
  .msg.resposta .msg-avatar { width: 32px; height: 32px; font-size: 13px; }
  .msg-num { display: none; }
  .msg-midia { max-width: none; }
  .msg-menu { right: 10px; left: 10px; min-width: 0; }

  .thread-toolbar { align-items: flex-start; flex-direction: column; }
  .global-media-head { align-items: flex-start; flex-direction: column; }
  .global-media-head h2 { font-size: 25px; }

  .programacao-item { grid-template-columns: 62px minmax(0, 1fr); gap: 10px; padding: 11px 12px; }
  .programacao-hora { font-size: 15px; }

  .modal-foot { flex-direction: column-reverse; }
  .modal-foot button { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* Impressão da programação */
@media print {
  .topbar, .composer, .msg-acoes, .instalar-faixa, .toast, .novas-msgs { display: none !important; }
  body { background: #fff; }
}
