:root {
  --bg: #13100d;
  --panel: #1b1713;
  --panel-2: #241e19;
  --panel-3: #2f2720;
  --line: #372e26;
  --text: #f4ede4;
  --muted: #a6978a;
  --faint: #75695e;
  --accent: #ff7a3d;
  --accent-hi: #ff9a66;
  --accent-ink: #2a1206;
  --teal: #2bb3a3;
  --live: #ff4d5e;
  --radius: 20px;
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1100px 600px at 0% -10%, rgba(255, 122, 61, .11), transparent 60%),
    radial-gradient(900px 520px at 110% 110%, rgba(43, 179, 163, .08), transparent 60%);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- marca ---------- */
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: -.03em;
}
.brand.big { font-size: 44px; gap: 14px; justify-content: center; }
.logo {
  display: inline-block; width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='%232a1206'%3E%3Cpath d='M16 3.5l-1.8 5.5h3.6z'/%3E%3Cpath d='M10.5 4.5l2.6 4.6-3 .4z'/%3E%3Cpath d='M21.5 4.5l-2.6 4.6 3 .4z'/%3E%3Cpath d='M2 12.5l6.5 2.3-6.5 1.4z'/%3E%3Cpath d='M30 12.5l-6.5 2.3 6.5 1.4z'/%3E%3Cpath d='M2 19l5.5.3-5.5 2.2z'/%3E%3Cpath d='M30 19l-5.5.3 5.5 2.2z'/%3E%3Cpath d='M8.5 14.5q3-2.2 5.5.3-3 1.6-5.5-.3z'/%3E%3Cpath d='M23.5 14.5q-3-2.2-5.5.3 3 1.6 5.5-.3z'/%3E%3C/g%3E%3Ccircle cx='13.6' cy='23.5' r='3.6' fill='%23fff1e2'/%3E%3Ccircle cx='18.4' cy='23.5' r='3.6' fill='%23fff1e2'/%3E%3Cpath d='M13.8 19.6h4.4l-2.2 2.8z' fill='%232a1206'/%3E%3Cpath d='M16 22.4v2.2' stroke='%232a1206' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  box-shadow: 0 6px 20px -6px rgba(255, 122, 61, .6);
}
.brand.big .logo { width: 56px; height: 56px; border-radius: 17px; }
.logo.xl { width: 88px; height: 88px; border-radius: 28px; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2);
  font-weight: 700; transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hi); }
.btn.danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn.on { border-color: var(--teal); color: var(--teal); background: rgba(43, 179, 163, .12); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.btn.small svg { width: 16px; height: 16px; }
.btn.wide { width: 100%; height: 50px; font-size: 16px; }
.btn.disabled { opacity: .5; }

.icon-btn {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center;
  border-radius: 12px; border: 0; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.solid { background: var(--accent); color: var(--accent-ink); font-size: 20px; font-weight: 700; }
.icon-btn.solid:hover { background: var(--accent-hi); }

.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 11px;
  display: inline-grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 15px; color: #1a1410;
}
.avatar.sm { width: 24px; height: 24px; border-radius: 8px; font-size: 12px; }
.pill {
  padding: 3px 10px; border-radius: 999px; background: var(--panel-2);
  color: var(--muted); font-size: 12.5px; font-weight: 500;
}
.live {
  padding: 2px 7px; border-radius: 6px; background: var(--live); color: #fff;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
}

/* ---------- entrada ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(420px, 100%); display: flex; flex-direction: column; gap: 22px;
  padding: 36px 28px; border-radius: 28px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7);
}
.tagline { margin: -8px 0 4px; text-align: center; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; font-weight: 500; font-size: 14px; color: var(--muted); }
.field input {
  height: 50px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 11px; border: 3px solid transparent; }
.swatch.sel { border-color: var(--text); transform: scale(1.08); }

/* ---------- layout do app ---------- */
.app {
  height: 100vh; height: 100dvh;
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: 250px minmax(0, 1fr) 350px;
  grid-template-rows: 56px minmax(0, 1fr);
}
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding: 0 6px; }
.room-title {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  font-family: var(--display); font-weight: 600; font-size: 19px;
}
.room-title #roomName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(43, 179, 163, .16); flex: none; }
.conn.off { background: var(--live); box-shadow: 0 0 0 4px rgba(255, 77, 94, .16); }
.me {
  margin-left: auto; padding-right: 4px !important; display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 4px 4px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
}
.me-name { font-weight: 700; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side, .stage, .chat {
  min-height: 0; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
}

/* salas */
.side { padding: 14px; display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.side-title {
  margin: 8px 6px 6px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
}
.room-list { display: flex; flex-direction: column; gap: 4px; }
.room {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 14px; border: 0; background: transparent;
  color: var(--muted); text-align: left; font-weight: 500;
}
.room:hover { background: var(--panel-2); color: var(--text); }
.room.active { background: var(--panel-3); color: var(--text); font-weight: 700; }
.room-ic {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--panel-2); color: var(--accent);
}
.room.active .room-ic { background: var(--accent); color: var(--accent-ink); }
.room-ic svg { width: 16px; height: 16px; }
.room-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-count { font-size: 12px; color: var(--faint); min-width: 12px; text-align: right; }

.new-room { display: flex; gap: 6px; margin: 6px 0 10px; }
.new-room input {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px; border-radius: 12px;
  border: 1px dashed var(--line); background: transparent;
}
.new-room input:focus { outline: none; border-style: solid; border-color: var(--accent); }

.members li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 12px; }
.members .m-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members .m-you { color: var(--faint); font-size: 12.5px; }
.members .m-icons { display: flex; gap: 4px; color: var(--teal); }
.members .m-icons svg { width: 16px; height: 16px; }
.members .m-icons .is-live { color: var(--live); }

/* palco */
.stage { position: relative; display: flex; flex-direction: column; overflow: hidden; }
.tiles {
  flex: 1; min-height: 0; padding: 12px; display: grid; gap: 10px; overflow: auto;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  grid-auto-rows: minmax(200px, 1fr);
}
.tiles[data-count="0"] { display: none; }
.tiles[data-count="1"] { grid-template-columns: 1fr; }
.tiles.focused { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); grid-template-rows: minmax(0, 1fr); grid-auto-rows: 120px; }
.tile {
  position: relative; min-height: 0; overflow: hidden; cursor: zoom-in;
  border-radius: 16px; background: #0b0907; border: 1px solid var(--line);
}
.tile.is-focus { grid-column: 1 / -1; order: -1; cursor: zoom-out; border-color: var(--accent); }
.tile.local-off { cursor: default; display: grid; place-items: center; background: var(--panel-2); }
.local-off-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px; text-align: center; }
.local-off-box strong { font-family: var(--display); font-size: 20px; }
.local-off-box strong::before {
  content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%;
  background: var(--live); box-shadow: 0 0 0 4px rgba(255, 77, 94, .2); vertical-align: 2px;
}
.local-off-box span { color: var(--muted); font-size: 14px; max-width: 300px; }
.local-off-box .btn { margin-top: 6px; height: 38px; }
.tile video { width: 100%; height: 100%; display: block; object-fit: contain; background: #0b0907; }
.tile:fullscreen { border-radius: 0; border: 0; }
.tile-bar {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 6px;
  border-radius: 14px; background: rgba(19, 16, 13, .75); backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s;
}
.tile:hover .tile-bar, .tile:focus-within .tile-bar, .tile.is-focus .tile-bar { opacity: 1; transform: none; }
.tile-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-bar .spacer { flex: 1; }
.tile-bar .icon-btn { width: 30px; height: 30px; border-radius: 10px; color: var(--text); }
.vol { width: 90px; accent-color: var(--accent); }

.empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px 16px; text-align: center;
}
.empty-art { padding: 26px; border-radius: 40px; background: var(--panel-2); margin-bottom: 14px; }
.empty h2 { margin: 0; font-family: var(--display); font-size: 26px; letter-spacing: -.02em; }
.empty p { margin: 0; max-width: 380px; color: var(--muted); }

.sound-banner {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 10px 18px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .7);
}

.controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
  padding: 12px; border-top: 1px solid var(--line); background: rgba(36, 30, 25, .5);
}
.select select {
  height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); font-weight: 500;
}

/* conversa */
.chat { display: flex; flex-direction: column; overflow: hidden; }
.chat-head {
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
  font-family: var(--display); font-weight: 600; font-size: 17px;
}
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 16px 14px; }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-name { font-weight: 700; }
.msg-time { font-size: 11.5px; color: var(--faint); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; color: #e8dfd4; }
.msg-text + .msg-text { margin-top: 3px; }
.sys { margin: 14px 0 0; text-align: center; font-size: 12.5px; color: var(--faint); }
.sys span { padding: 3px 10px; border-radius: 999px; background: var(--panel-2); }

.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.composer input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2);
}
.composer input:focus { outline: none; border-color: var(--accent); }
.composer .icon-btn { width: 44px; height: 44px; border-radius: 14px; }

/* aviso */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 10; max-width: calc(100% - 32px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 500;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- telas menores ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 210px minmax(0, 1fr) 300px; }
}
@media (max-width: 860px) {
  .app { height: auto; min-height: 100vh; display: flex; flex-direction: column; padding: 10px 16px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 4px 0; }
  .room-title { order: 3; width: 100%; font-size: 17px; }
  .stage { min-height: 58vh; }
  .tiles { grid-template-columns: 1fr; }
  .chat { height: 70vh; }
  .side { order: 5; }
  .vol { width: 64px; }
  .controls .btn, .select select { height: 42px; }
}
