:root {
  --fundo: #0b1220;
  --cartao: #131c2e;
  --cartao-2: #182339;
  --borda: #263247;
  --primario: #2f80ed;
  --primario-2: #1f6fd9;
  --perigo: #e5484d;
  --perigo-2: #cc3a3f;
  --texto: #e6edf7;
  --suave: #9fb0c7;
  --ok: #3ecf8e;
  --raio: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  background: var(--fundo);
  background-image: radial-gradient(circle at 12% 20%, rgba(47, 128, 237, .14), transparent 30%), radial-gradient(circle at 88% 80%, rgba(62, 207, 142, .08), transparent 30%);
  color: var(--texto);
}
button, input { font: inherit; color: inherit; }

/* ---------- lobby ---------- */
.lobby { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.cartao { width: 100%; max-width: 440px; background: var(--cartao); border: 1px solid var(--borda); border-radius: 16px; padding: 2rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.logo { display: flex; align-items: center; justify-content: center; gap: .6rem; font-size: 2rem; letter-spacing: -.02em; }
.logo-icone { display: inline-block; width: 1.1em; height: .75em; border: .12em solid var(--primario); border-radius: .18em; position: relative; }
.logo-icone::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: -.32em; height: .1em; background: var(--primario); border-radius: 1px; }
.sub { text-align: center; color: var(--suave); margin: .5rem 0 1.5rem; line-height: 1.4; }
.rodape-lobby { text-align: center; color: var(--suave); font-size: .8rem; margin-top: 1.25rem; }
.campo { display: block; font-size: .85rem; color: var(--suave); margin-bottom: 1rem; }
.campo input { display: block; width: 100%; margin-top: .4rem; padding: .7rem .9rem; border-radius: 8px; border: 1px solid var(--borda); background: var(--fundo); color: var(--texto); outline: none; }
.campo input:focus { border-color: var(--primario); box-shadow: 0 0 0 3px rgba(47, 128, 237, .2); }

/* ---------- abas ---------- */
.abas { display: flex; border-bottom: 1px solid var(--borda); margin-bottom: 1rem; }
.aba { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; padding: .6rem; cursor: pointer; color: var(--suave); font-weight: 600; position: relative; }
.aba.ativa { color: var(--texto); border-bottom-color: var(--primario); }
.aba.novo::after { content: ""; position: absolute; top: .5rem; margin-left: .3rem; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.conta { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: var(--cartao-2); font-size: .75rem; color: var(--suave); }
.painel { display: none; }
.painel.ativa { display: block; }

/* ---------- botões ---------- */
.botao { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: none; border-radius: 8px; padding: .75rem 1rem; font-weight: 600; cursor: pointer; transition: background .15s, transform .05s, opacity .15s; }
.botao:active { transform: scale(.98); }
.botao:disabled { opacity: .55; cursor: progress; }
form .botao { width: 100%; }
.botao.primario { background: var(--primario); color: #fff; }
.botao.primario:hover:not(:disabled) { background: var(--primario-2); }
.botao.perigo { background: var(--perigo); color: #fff; }
.botao.perigo:hover:not(:disabled) { background: var(--perigo-2); }
.botao.compacto { padding: .5rem .9rem; }
.icone-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; flex: none; }
.icone-btn:hover { background: rgba(255, 255, 255, .3); }

/* ---------- sala ---------- */
.sala { height: 100vh; display: flex; flex-direction: column; }
.topo, .rodape { display: flex; align-items: center; gap: 1rem; padding: .75rem 1.25rem; background: rgba(19, 28, 46, .85); backdrop-filter: blur(10px); }
.topo { justify-content: space-between; border-bottom: 1px solid var(--borda); }
.rodape { justify-content: center; border-top: 1px solid var(--borda); }
.sala-info { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.marca { display: flex; align-items: center; gap: .45rem; font-size: 1.1rem; }
.etiqueta { display: inline-flex; gap: .5rem; align-items: center; padding: .35rem .7rem; border-radius: 6px; border: none; background: rgba(47, 128, 237, .18); color: #a9cbff; font-family: ui-monospace, Consolas, monospace; cursor: pointer; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etiqueta:hover { background: rgba(47, 128, 237, .3); }
.opcao { display: flex; align-items: center; gap: .4rem; color: var(--suave); cursor: pointer; }

.conteudo { flex: 1; display: flex; min-height: 0; }
.grade { flex: 1; min-width: 0; padding: 1rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); grid-auto-rows: minmax(220px, 1fr); overflow: auto; align-content: stretch; }
.vazio { grid-column: 1 / -1; align-self: center; text-align: center; color: var(--suave); line-height: 1.6; }
.video-bloco { position: relative; background: #000; border-radius: var(--raio); overflow: hidden; border: 1px solid var(--borda); min-height: 0; }
.video-bloco video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-bloco.local { border-color: rgba(47, 128, 237, .6); }
.sobre { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; align-items: flex-end; gap: .5rem; padding: .75rem; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); opacity: 0; transition: opacity .2s; }
.video-bloco:hover .sobre, .video-bloco:focus-within .sobre { opacity: 1; }
.rotulo { background: rgba(0, 0, 0, .55); padding: .25rem .6rem; border-radius: 4px; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controles { display: flex; align-items: center; gap: .4rem; }
.volume { width: 80px; cursor: pointer; accent-color: var(--primario); }
.video-bloco.sem-som::before { content: "🔇 toque pra ouvir"; position: absolute; top: .6rem; left: .6rem; z-index: 1; background: rgba(0, 0, 0, .6); padding: .2rem .5rem; border-radius: 4px; font-size: .8rem; }

.lateral { width: 320px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--borda); background: rgba(11, 18, 32, .7); padding: .75rem; min-height: 0; }
.lateral .abas { margin-bottom: .5rem; }
.lista { list-style: none; overflow-y: auto; }
.participante { display: flex; align-items: center; gap: .6rem; padding: .5rem .25rem; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primario); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; }
.participante .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selo { font-size: .72rem; color: var(--suave); background: var(--cartao-2); padding: .1rem .45rem; border-radius: 999px; }
.selo.tela { background: rgba(62, 207, 142, .15); color: var(--ok); }

.chat.ativa { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mensagens { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .6rem; padding: .25rem; }
.balao { align-self: flex-start; max-width: 90%; background: rgba(255, 255, 255, .08); padding: .55rem .75rem; border-radius: 10px; border-top-left-radius: 2px; overflow-wrap: anywhere; }
.balao.minha { align-self: flex-end; background: rgba(47, 128, 237, .28); border-top-left-radius: 10px; border-top-right-radius: 2px; }
.autor { font-size: .72rem; color: var(--suave); margin-bottom: .2rem; }
.texto { white-space: pre-wrap; }
.arquivo { color: var(--texto); text-decoration: none; display: inline-block; padding: .35rem .5rem; border-radius: 6px; background: rgba(0, 0, 0, .25); }
.arquivo:hover { background: rgba(0, 0, 0, .45); }
.progresso { font-size: .78rem; color: var(--suave); display: flex; flex-direction: column; gap: .2rem; }
.progresso progress { width: 100%; height: 6px; accent-color: var(--primario); }
.chat-entrada { display: flex; gap: .4rem; align-items: center; padding-top: .5rem; }
.chat-entrada input[type="text"] { flex: 1; min-width: 0; padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--borda); background: var(--fundo); outline: none; }
.chat-entrada input[type="text"]:focus { border-color: var(--primario); }
.anexo { background: var(--cartao-2); }

/* ---------- avisos ---------- */
.toasts { position: fixed; left: 1rem; bottom: 5rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--cartao); border: 1px solid var(--borda); border-left: 4px solid var(--primario); padding: .75rem 1rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: entra .25s ease-out; transition: opacity .4s; }
.toast.erro { border-left-color: var(--perigo); }
.toast.aviso { border-left-color: #f5a524; }
.toast.saindo { opacity: 0; }
@keyframes entra { from { transform: translateX(-20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- celular ---------- */
@media (max-width: 800px) {
  .conteudo { flex-direction: column; }
  .grade { grid-template-columns: 1fr; grid-auto-rows: minmax(200px, 1fr); }
  .lateral { width: auto; height: 40vh; border-left: none; border-top: 1px solid var(--borda); }
  .topo, .rodape { padding: .6rem .9rem; }
  .sobre { opacity: 1; }
}
