/* ---------------------------------------------------------------- base */
:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #171b25;
  --raise: #1d2230;
  --line: #242a3a;
  --txt: #e7eaf3;
  --muted: #8b93a7;
  --dim: #7b8398;
  --accent: #6c8cff;
  --accent-2: #9d7bff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --radius: 12px;
  --sidebar-w: 284px;

  --txt-body: #d7dcea;
  --on-accent: #0b0d12;
  --line-soft: #33405e;
  --scroll: #2a3145;
  --scroll-hover: #3a4460;
  --live-line: #3a2c46;
  --voice-line: #24402f;
}

/* Tema claro. O JavaScript resolve "sistema" e sempre grava dark ou light aqui,
   entao o CSS so precisa conhecer os dois estados concretos. */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef1f8;
  --raise: #e3e8f4;
  --line: #d7dced;
  --txt: #171a23;
  --muted: #545c70;
  --dim: #636a7c;
  --accent: #4059e0;
  --accent-2: #7b4ddb;
  --ok: #12996a;
  --warn: #a86b00;
  --danger: #d13b3b;

  --txt-body: #262b38;
  --on-accent: #ffffff;
  --line-soft: #b9c2dc;
  --scroll: #c3cadd;
  --scroll-hover: #a7b0c9;
  --live-line: #d5c9ee;
  --voice-line: #b6e0cd;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--txt);
  font: 16px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------- marca */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(108, 140, 255, 0.35);
}

.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.brand-name {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-lg { justify-content: center; font-size: 22px; }
.brand-lg .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.brand-lg .brand-mark svg { width: 27px; height: 27px; }

/* --------------------------------------------------------- tela entrada */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(108, 140, 255, 0.20), transparent 60%),
    radial-gradient(800px 500px at 90% 110%, rgba(157, 123, 255, 0.18), transparent 60%),
    var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.gate-sub {
  margin: 14px 0 24px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }

.gate-hint { margin: 12px 0 0; min-height: 18px; text-align: center; font-size: 13px; color: var(--danger); }

/* -------------------------------------------------------------- layout */
.app { display: flex; height: 100%; }

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar > .brand { padding: 16px 18px; border-bottom: 1px solid var(--line); }

.pane { padding: 14px 10px; border-bottom: 1px solid var(--line); min-height: 0; }
.pane-grow { flex: 1; display: flex; flex-direction: column; border-bottom: 0; }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--dim);
}

.badge {
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--raise);
  font-size: 12px;
  color: var(--muted);
}

.room-list, .chan-list, .group-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.group-list { max-height: 22vh; }
.chan-list { flex: 1; }

.room-list li, .chan-list li, .group-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--muted);
  cursor: default;
}

.room-list li, .chan-list li, .group-list li { cursor: pointer; }
.chan-list li:hover, .group-list li:hover { background: var(--panel-2); color: var(--txt); }
.chan-list li.active, .group-list li.active { background: var(--raise); color: var(--txt); font-weight: 600; }
.chan-list .hash { flex: 0 0 18px; color: var(--dim); font-weight: 700; font-size: 15px; }
.chan-list .count { margin-left: auto; font-size: 12px; color: var(--dim); }

/* Reserva o espaco sempre (visibility, nao display) para a linha nao pular
   quando o cursor passa por cima. */
.room-del {
  visibility: hidden;
  display: grid;
  place-items: center;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.chan-list li:hover .room-del, .group-list li:hover .room-del { visibility: visible; }
.room-del:hover { background: var(--danger); color: #fff; }

/* Armado: fica visível mesmo sem o cursor em cima, senão o segundo clique
   viraria adivinhação. */
.room-del.armed {
  visibility: visible;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
}

.inline-new {
  width: calc(100% - 18px);
  margin: 6px 9px 2px;
  padding: 9px 11px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--panel-2);
  outline: none;
  font-size: 14.5px;
}

.inline-new::placeholder { color: var(--dim); }


.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 29px;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.me {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.me-nick { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { background: var(--raise); color: var(--txt); }

.profile-card {
  position: fixed;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 250px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--raise);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.profile-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.profile-info { min-width: 0; }
.profile-nick { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-meta { margin-top: 3px; font-size: 12px; line-height: 1.45; color: var(--muted); }

.group-mark {
  display: grid;
  place-items: center;
  flex: 0 0 25px;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* Canal de voz conectado fica verde: o estado precisa ser lido de relance. */
.chan-list li.connected { color: var(--ok); }
.chan-list li.connected .hash { color: var(--ok); }

.voice-member:hover { background: var(--panel-2); }

.voice-member {
  padding-left: 26px !important;
  font-size: 14px;
  cursor: default !important;
}

.voice-member .avatar { flex: 0 0 21px; width: 21px; height: 21px; font-size: 10px; }

/* Quem está falando: anel verde no avatar, como no Discord. A transição curta
   no apagar evita pisca-pisca entre sílabas. */
.voice-member.speaking .avatar {
  box-shadow: 0 0 0 2px var(--ok), 0 0 10px rgba(61, 220, 151, 0.55);
}

.voice-member.speaking .nick { color: var(--ok); }
.voice-member .avatar { transition: box-shadow 0.12s ease-out; }
.voicebar.speaking .call-dot { animation: pulse 0.9s infinite; }

.chan-new { padding: 4px 0 2px; }
.chan-kind {
  display: flex;
  gap: 14px;
  padding: 7px 12px 2px;
  font-size: 13px;
  color: var(--muted);
}
.chan-kind label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.chan-kind input { accent-color: var(--accent); }

.voicebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  background: rgba(61, 220, 151, 0.08);
  font-size: 14px;
}

.voicebar[data-mic="off"] { background: rgba(255, 107, 107, 0.10); }
.voicebar[data-mic="off"] .call-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.voice-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--txt); }

/* ------------------------------------------------ painel de áudio */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 22px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-size: 17px;
  font-weight: 600;
}

.modal .field select,
.modal .field input[type="range"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  outline: none;
}

.modal .field input[type="range"] { padding: 0; accent-color: var(--accent); }
.modal .field span b { color: var(--txt); font-weight: 600; }

.modal-hint { margin: 6px 0 18px; font-size: 12.5px; color: var(--dim); min-height: 16px; }

/* Barra de nível: confirma que o microfone escolhido está mesmo captando. */
.meter {
  height: 8px;
  margin-top: 8px;
  border-radius: 6px;
  background: var(--panel-2);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--ok), var(--accent));
  transition: width 0.08s linear;
}

/* -------------------------------------------------------------- centro */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  height: 62px;
  flex: 0 0 62px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.room-title { margin: 0; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.status[data-state="on"]::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status[data-state="off"]::before { background: var(--danger); }
.status[data-state="connecting"]::before { animation: pulse 1.1s infinite; }

@keyframes pulse { 50% { opacity: 0.25; } }

/* ------------------------------------------------- transmissao de tela */
.share-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.share-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-btn:hover { color: var(--txt); border-color: var(--line-soft); background: var(--raise); }

.share-btn[data-on="1"] {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.share-btn:disabled { opacity: 0.45; cursor: default; }

.live-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse 1.4s infinite;
}

.live {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 18px 0;
  padding: 10px 14px;
  border: 1px solid var(--live-line);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(157, 123, 255, 0.16), rgba(108, 140, 255, 0.08));
  font-size: 13.5px;
}

.live-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.live-watch {
  padding: 6px 14px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.live-watch:hover { filter: brightness(1.1); }

.stage {
  display: flex;
  flex-direction: column;
  margin: 12px 18px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #05070b;  /* letterbox escuro nos dois temas, de proposito */
  overflow: hidden;
}

.stage video {
  width: 100%;
  max-height: 46vh;
  min-height: 160px;
  background: #05070b;
  object-fit: contain;
  display: block;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
}

.stage-who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.stage-btn {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}

.stage-btn:hover { color: var(--txt); background: var(--raise); }
.stage-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* Dois botoes seguidos: so o primeiro empurra; o segundo cola ao lado. */
.share-btn + .share-btn { margin-left: 8px; }

.call-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.callbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 18px 0;
  padding: 9px 14px;
  border: 1px solid var(--voice-line);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(61, 220, 151, 0.14), rgba(61, 220, 151, 0.04));
  font-size: 13.5px;
}

.call-who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.share-btn[data-mic="off"] {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}

/* Um contêiner só para as etiquetas: com margin-left:auto em cada uma, duas
   etiquetas dividiriam o espaço livre e ficariam separadas no meio da linha. */
.tags {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.tag.voz { color: var(--ok); }
.tag.tela { color: var(--accent); }

.tag svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Embaixo do canal de voz só cabe o ícone; o nome do canal já dá o contexto. */
.voice-member .tag.tela { margin-left: auto; }

/* ----------------------------------------------------------- mensagens */
.messages { flex: 1; overflow-y: auto; padding: 18px 18px 8px; }

.msg { display: flex; gap: 11px; padding: 3px 0; }
.msg + .msg.grouped { padding-top: 1px; }
.msg .avatar { margin-top: 3px; }
.msg.grouped .avatar { visibility: hidden; height: 0; margin: 0; }
.msg-body { min-width: 0; flex: 1; }

.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-head .who { font-weight: 600; font-size: 15px; }
.msg-head .when { font-size: 12px; color: var(--dim); }

.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--txt-body);
}

.msg-text a { color: var(--accent); }
.msg.mine .msg-head .who { color: var(--accent); }

.msg.emote .msg-text { font-style: italic; color: var(--muted); }

.sys {
  margin: 8px 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--dim);
}

.sys span {
  padding: 3px 12px;
  border-radius: 20px;
  background: var(--panel-2);
}

.daysep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.daysep::before, .daysep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.jump {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--raise);
  color: var(--txt);
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.typing { height: 20px; padding: 0 20px; font-size: 12px; color: var(--dim); font-style: italic; }

/* ---------------------------------------------------------- compositor */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 18px 18px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  transition: border-color 0.15s;
}

.composer:focus-within { border-color: var(--line-soft); }

.composer textarea {
  flex: 1;
  max-height: 160px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  overflow-y: auto;
  line-height: 1.45;
}

.composer textarea::placeholder { color: var(--dim); }

.send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}

.send svg { width: 18px; height: 18px; fill: #fff; }
.send:hover { filter: brightness(1.1); }
.send:disabled { opacity: 0.4; cursor: default; filter: none; }

/* -------------------------------------------------------------- mobile */
.only-mobile { display: none; }
.scrim { display: none; }

@media (max-width: 760px) {
  .only-mobile { display: grid; }

  .sidebar {
    position: fixed;
    z-index: 20;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }

  .app.drawer .sidebar { transform: none; }

  .app.drawer .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.55);
  }

  .messages { padding: 14px 12px 6px; }
  .composer { margin: 0 12px 12px; }

  .share-btn span { display: none; }  /* so o icone cabe ao lado do titulo */
  .share-btn { padding: 6px 9px; }
  .live, .stage { margin-left: 12px; margin-right: 12px; }
  .stage video { max-height: 38vh; }
}
