:root{
  --bg:#f5f7fb; --text:#0b1020; --muted:#6b7280; --card:#ffffff; --border:#e5e7eb; --accent:#4f46e5; --accent-2:#10b981;
  --danger:#ef4444; --sidebar:#0b1220; --sidebar-text:#d6e0ff; --purple:#8b5cf6;
}
html[data-theme="dark"]{
  --bg:#0b1020; --text:#e5e7eb; --muted:#94a3b8; --card:#111827; --border:#1f2937; --accent:#818cf8; --accent-2:#34d399;
  --danger:#f87171; --sidebar:#090e1a; --sidebar-text:#c7d2fe;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif}
.hidden{display:none !important}
.small{font-size:.85rem}
.muted{color:var(--muted)}
.badge{display:inline-block;padding:.1rem .4rem;border-radius:999px;background:transparent;border:1px solid var(--border)}
.row{display:flex;align-items:center}
.end{justify-content:flex-end}
.gap>*{margin-right:.5rem}
.gap>*:last-child{margin-right:0}
.full{width:100%}
.card{background:var(--card);border:1px solid var(--border);border-radius:16px;padding:1rem}

.auth-wrapper{display:grid;min-height:100vh;place-items:center}
.auth{min-width:320px;max-width:360px;box-shadow:0 8px 24px rgba(0,0,0,.15)}
.auth input, .auth select{width:100%;margin:.4rem 0;padding:.7rem;border:1px solid var(--border);border-radius:10px;background:transparent;color:var(--text)}
.auth button{padding:.65rem .9rem;border-radius:10px;border:1px solid var(--border);background:transparent;color:var(--text);cursor:pointer}
.btn-primary{background:var(--accent);color:white;border-color:var(--accent)}
.btn{padding:.5rem .75rem;border:1px solid var(--border);border-radius:10px;background:transparent;color:var(--text);cursor:pointer}
.btn-danger{background:var(--danger);color:white;border:none}
.link{background:transparent;border:none;color:var(--sidebar-text);text-decoration:underline;cursor:pointer}

.app{display:grid;grid-template-columns:300px 1fr;height:100vh}
.sidebar{background:var(--sidebar);color:var(--sidebar-text);padding:1rem;overflow:auto}
.sidebar .me{display:flex;gap:.8rem;margin-bottom:1rem}
.avatar{width:36px;height:36px;border-radius:50%;object-fit:cover}
.avatar.lg{width:48px;height:48px}
.me-name-row{display:flex;align-items:center;gap:.4rem}
.badge.admin{color:var(--purple);font-weight:700;border-color:var(--purple)}
.status-select, select, input{background:transparent;color:inherit;border:1px solid var(--border);border-radius:10px;padding:.45rem .6rem}
.section-title{margin:.75rem 0 .3rem;font-weight:700;opacity:.9}
.list{list-style:none;margin:.25rem 0 0;padding:0;display:flex;flex-direction:column;gap:.25rem}
.list li{padding:.45rem .55rem;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:rgba(255,255,255,.05);cursor:pointer;display:flex;justify-content:space-between;align-items:center}
.list li:hover{background:rgba(255,255,255,.12)}
.pill-list{display:flex;flex-wrap:wrap;gap:.4rem;margin:.5rem 0}
.pill{padding:.25rem .5rem;border-radius:999px;background:#1f2937;color:#e5e7eb;border:1px solid #374151;font-size:.8rem}
.file{display:none}

.main{display:grid;grid-template-rows:auto 1fr;overflow:hidden}
.header{display:flex;justify-content:space-between;align-items:center;padding:1rem;border-bottom:1px solid var(--border);background:var(--card)}
.room-title{display:flex;align-items:center;gap:.6rem}
.verified{color:var(--accent-2);font-weight:700}

.chat{display:grid;grid-template-rows:1fr auto;background:var(--bg)}
.messages{padding:1rem;overflow:auto}
.msg{display:flex;gap:.6rem;margin:.35rem 0}
.msg .bubble{background:var(--card);border:1px solid var(--border);padding:.5rem .7rem;border-radius:12px;max-width:70%}
.msg .meta{font-size:.75rem;color:var(--muted)}
.msg img.image{max-width:240px;border-radius:10px;margin-top:.4rem;border:1px solid var(--border)}
.msg .name{font-weight:700}
.msg .admin{color:var(--purple);font-weight:700;margin-left:.25rem}
.msg .tools{margin-left:.3rem}
.typing{height:20px;padding:0 1rem;color:var(--muted);font-style:italic}
.composer{display:flex;gap:.5rem;padding:.8rem;border-top:1px solid var(--border);background:var(--card)}
.composer textarea{flex:1;min-height:42px;max-height:140px;resize:vertical;border-radius:10px;border:1px solid var(--border);padding:.6rem}

.modal::backdrop{background:rgba(0,0,0,.45)}
.modal .card{min-width:420px}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}

.toast{position:fixed;bottom:14px;left:50%;transform:translateX(-50%);background:var(--card);border:1px solid var(--border);padding:.6rem .9rem;border-radius:12px;box-shadow:0 8px 22px rgba(0,0,0,.2)}
