:root {
  --bg: #07060f;
  --bg-2: #0d0a1c;
  --panel: #120d24;
  --panel-2: #1a1336;
  --border: #2b2150;
  --border-2: #3a2c6e;
  --text: #ece9ff;
  --muted: #9a92c4;
  --violet: #a855f7;
  --violet-2: #c084fc;
  --cyan: #22d3ee;
  --danger: #fb7185;
  --ok: #34d399;
  --radius: 14px;
  --glow: 0 0 30px rgba(168,85,247,.35);
  --sidebar: #0b0818;
  font-family: 'Rajdhani', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1000px 500px at 85% -5%, rgba(168,85,247,.18), transparent 60%),
              radial-gradient(800px 500px at 0% 10%, rgba(34,211,238,.12), transparent 55%),
              var(--bg);
  color: var(--text); line-height: 1.5; overflow: hidden; height: 100vh;
  display: flex; flex-direction: column;
}
a { color: var(--cyan); text-decoration: none; }

.bg-grid { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(168,85,247,.06) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(168,85,247,.06) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 75%); }

.btn { font-family: 'Rajdhani'; font-weight: 700; letter-spacing: .5px; border: none; border-radius: 10px; cursor: pointer;
  padding: 10px 16px; font-size: 14px; transition: transform .12s, box-shadow .2s, background .2s; }
.btn:active { transform: translateY(0); }
.btn--primary { background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #0a0716; box-shadow: var(--glow); }
.btn--primary:hover { box-shadow: 0 0 42px rgba(34,211,238,.5); }
.btn--ghost { background: transparent; color: var(--text); border: 1px solid var(--border-2); }
.btn--ghost:hover { border-color: var(--violet); color: var(--violet-2); }
.btn--small { padding: 7px 12px; font-size: 13px; }
.btn--danger { background: rgba(251,113,133,.12); color: var(--danger); border: 1px solid rgba(251,113,133,.3); }
.btn--danger:hover { background: rgba(251,113,133,.22); }
.btn--block { width: 100%; padding: 14px; font-size: 16px; }

/* TOPBAR */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px;
  background: rgba(7,6,15,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__logo { color: var(--violet); font-size: 22px; text-shadow: var(--glow); }
.topbar__name { font-family: 'Orbitron'; font-weight: 900; letter-spacing: 2px; }
.topbar__sub { color: var(--cyan); font-size: 12px; letter-spacing: 1px; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.nav-user { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border-2); padding: 6px 12px; border-radius: 10px; }
.nav-user__avatar { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #0a0716; display: grid; place-items: center; font-weight: 800; font-family: 'Orbitron'; }
.nav-user span { font-weight: 700; }
.nav-user__logout { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; }
.nav-user__logout:hover { color: var(--danger); }

/* LAYOUT */
.layout { flex: 1; display: grid; grid-template-columns: 260px 1fr 240px; min-height: 0; }
.side { background: var(--sidebar); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.side__channel { font-family: 'Orbitron'; font-weight: 700; font-size: 15px; padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); }
.side__hash { color: var(--violet-2); margin-right: 4px; }
.side__label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-top: 10px; padding: 0 10px; }
.online { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.online li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; transition: background .15s; }
.online li:hover { background: var(--panel); }
.online .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); flex-shrink: 0; }
.online .dot--voice { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.online .name { font-weight: 600; font-size: 14px; }
.online .tag { font-size: 10px; color: var(--muted); margin-left: auto; }
.side__hint { margin-top: auto; font-size: 11px; color: #6b6390; padding: 10px; line-height: 1.4; }

.main { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); }
.main__header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-family: 'Orbitron'; font-weight: 700; font-size: 16px; display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; }
.main__hash { color: var(--violet-2); }
.main__room { font-family: 'Rajdhani'; font-weight: 500; font-size: 13px; color: var(--muted); }

.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg__avatar { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #0a0716; display: grid; place-items: center; font-weight: 800; font-family: 'Orbitron'; flex-shrink: 0; }
.msg__body { min-width: 0; }
.msg__head { display: flex; align-items: baseline; gap: 8px; }
.msg__author { font-weight: 700; font-family: 'Orbitron'; font-size: 13px; color: var(--violet-2); }
.msg__time { font-size: 11px; color: var(--muted); }
.msg__text { color: var(--text); font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg__text.system { color: var(--muted); font-style: italic; }

.composer { padding: 12px 18px 18px; border-top: 1px solid var(--border); flex-shrink: 0; }
.composer__lock { text-align: center; }
.composer__form { display: flex; gap: 10px; align-items: flex-end; }
.composer__form textarea { flex: 1; resize: none; max-height: 140px; padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border-2); color: var(--text); font-family: inherit; font-size: 15px; }
.composer__form textarea:focus { outline: none; border-color: var(--violet); }

.voice-bar { display: flex; align-items: center; gap: 12px; padding: 8px 18px; background: rgba(34,211,238,.08); border-top: 1px solid var(--border-2); flex-shrink: 0; }
.voice-bar__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
#voice-status { font-weight: 700; font-size: 14px; }

/* VOICE TILES */
.tiles { background: var(--sidebar); border-left: 1px solid var(--border); padding: 14px; display: grid; align-content: start; gap: 12px; grid-auto-rows: min-content; overflow-y: auto; }
.tile { position: relative; background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; overflow: hidden; aspect-ratio: 16/10; display: grid; place-items: center; }
.tile video, .tile audio { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile__name { position: absolute; bottom: 6px; left: 8px; font-size: 12px; font-weight: 700; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 6px; }
.tile__mic { position: absolute; top: 6px; right: 8px; font-size: 12px; }

/* MODAL */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.flex { display: flex; }
.modal.hidden { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(4,3,10,.78); backdrop-filter: blur(4px); }
.modal__box { position: relative; width: min(560px, 94vw); background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; padding: 28px; box-shadow: var(--glow); }
.modal__close { position: absolute; top: 16px; right: 18px; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal__close:hover { color: var(--danger); }
.modal__box h3 { font-family: 'Orbitron'; margin-bottom: 4px; }
.modal__sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.tabs { display: flex; gap: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 5px; margin-bottom: 20px; }
.tab { flex: 1; padding: 10px; background: transparent; border: none; color: var(--muted); border-radius: 9px; cursor: pointer; font-weight: 700; font-family: 'Rajdhani'; font-size: 14px; }
.tab--active { background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #0a0716; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: block; font-weight: 600; color: var(--text); font-size: 14px; }
.form input, .form textarea { width: 100%; margin-top: 6px; padding: 11px 13px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: 15px; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--violet); }
.form__error { color: var(--danger); font-size: 13px; text-align: center; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--cyan); color: var(--text); padding: 12px 20px; border-radius: 10px; z-index: 200; font-weight: 600; box-shadow: var(--glow); }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side, .tiles { display: none; }
}
