:root {
  --bg: #0e1621;
  --sidebar: #17212b;
  --panel: #1e2c3a;
  --bubble-me: #2b5278;
  --bubble-other: #182533;
  --accent: #2aabee;
  --accent-dim: #1e96d1;
  --text: #e4e6eb;
  --muted: #8b9aab;
  --border: #101921;
  --online: #4caf50;
  --danger: #e17055;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; }
.app { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0; z-index: 20; }
}
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.brand {
  padding: 18px 20px 12px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #2aabee, #6c5ce7);
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand h1 { font-size: 18px; letter-spacing: -0.3px; }
.brand p { font-size: 11px; color: var(--muted); }
.me {
  margin: 14px 16px; padding: 12px; background: var(--panel); border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.me .name { font-weight: 600; font-size: 14px; }
.me .tag { font-size: 11px; color: var(--muted); }
.reroll {
  margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px;
}
.auth-actions { display: flex; gap: 8px; padding: 0 16px 8px; }
.auth-actions button {
  flex: 1; background: var(--panel); border: 1px solid #243140; color: var(--text);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; font: inherit; font-size: 12px;
}
.auth-actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.section-label {
  padding: 16px 20px 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
}
.rooms { flex: 1; overflow-y: auto; }
.room {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer; border-left: 3px solid transparent;
}
.room:hover { background: #1a2430; }
.room.active { background: #1a2736; border-left-color: var(--accent); }
.room .preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint {
  padding: 14px 16px; font-size: 11px; color: var(--muted); line-height: 1.45;
  border-top: 1px solid var(--border);
}
.chat { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-head {
  height: 62px; padding: 0 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border); background: var(--sidebar);
}
.menu-btn { display: none; background: none; border: 0; color: var(--text); font-size: 22px; cursor: pointer; }
@media (max-width: 800px) { .menu-btn { display: block; } }
.chat-head h2 { font-size: 16px; }
.chat-head .sub { font-size: 12px; color: var(--online); }
.messages {
  flex: 1; overflow-y: auto; padding: 24px 16px 12px;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(42,171,238,.04), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(108,92,231,.04), transparent 40%);
}
.day { text-align: center; margin: 8px 0 16px; }
.day span {
  background: rgba(0,0,0,.35); color: var(--muted); font-size: 12px;
  padding: 4px 10px; border-radius: 10px;
}
.row { display: flex; margin-bottom: 8px; gap: 8px; }
.row.me { flex-direction: row-reverse; }
.bubble { max-width: min(72%, 520px); padding: 8px 12px 6px; border-radius: 12px; }
.row.other .bubble { background: var(--bubble-other); border-top-left-radius: 4px; }
.row.me .bubble { background: var(--bubble-me); border-top-right-radius: 4px; }
.who { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.txt { font-size: 14.5px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.meta { text-align: right; font-size: 11px; color: #9bb; margin-top: 4px; opacity: .8; }
.composer {
  padding: 12px 16px 16px; display: flex; gap: 10px; align-items: flex-end;
  background: var(--sidebar); border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 140px;
  background: var(--panel); border: 1px solid #243140; color: var(--text);
  border-radius: 12px; padding: 12px 14px; font: inherit; outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.send {
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; cursor: pointer; font-size: 18px;
}
.empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; }
.empty h3 { color: var(--text); margin-bottom: 8px; }
.status { font-size: 11px; color: var(--muted); padding: 0 16px 8px; }
.status.err { color: var(--danger); }
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: none; place-items: center; z-index: 50; padding: 16px;
}
.modal-bg.show { display: grid; }
.modal {
  width: min(420px, 100%); background: var(--sidebar); border: 1px solid #243140;
  border-radius: 16px; padding: 22px;
}
.modal h3 { margin-bottom: 6px; }
.modal p { color: var(--muted); font-size: 13px; margin-bottom: 16px; line-height: 1.45; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.modal input {
  width: 100%; background: var(--panel); border: 1px solid #243140; color: var(--text);
  border-radius: 10px; padding: 11px 12px; font: inherit;
}
.modal .err { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 8px; }
.modal .btns { display: flex; gap: 8px; margin-top: 16px; }
.modal .btns button {
  flex: 1; border: 0; border-radius: 10px; padding: 11px; cursor: pointer; font: inherit; font-weight: 600;
}
.btn-ghost { background: var(--panel); color: var(--text); }
.btn-go { background: var(--accent); color: #fff; }

.lock { font-size: 10px; color: #55efc4; font-weight: 600; }
.fp { font-size: 10px; color: var(--muted); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-tools { display: none; gap: 6px; }
.dm-tools button {
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 16px;
}
.media { max-width: 240px; max-height: 240px; border-radius: 8px; display: block; margin: 4px 0; }
.callbox {
  display: none; position: fixed; inset: 0; background: #000; z-index: 80;
}
.callbox.show { display: block; }
.callbox #remoteV { width: 100%; height: 100%; object-fit: cover; }
.callbox #localV {
  position: absolute; right: 16px; top: 16px; width: 140px; height: 180px;
  object-fit: cover; border-radius: 12px; background: #222;
}
.callbox #btnHang {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #c0392b; color: #fff; border: 0; border-radius: 24px;
  padding: 12px 28px; cursor: pointer; font: inherit; font-weight: 600;
}
