:root {
  --bg: #12141a; --panel: #1a1d26; --panel2: #222634;
  --text: #e6e8ee; --muted: #8a90a3; --accent: #7c5cff; --accent2: #9d85ff;
  --border: #2b3040; --mine: #2a2f45;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden;
}
.screen { height: 100vh; }
a { color: var(--accent2); }
.muted { color: var(--muted); font-size: 13px; }
.error { color: #ff7b7b; margin-top: 8px; }

/* login */
#login { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: min(380px, 92vw);
}
.login-card h1 { font-size: 26px; margin-bottom: 4px; }
.logo { color: var(--accent); }
.tagline { color: var(--muted); margin-bottom: 20px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card input, #composer input {
  width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.login-card button, #composer button {
  width: 100%; padding: 11px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600;
}
.login-card button:hover, #composer button:hover { background: var(--accent2); }
.hint { margin-top: 16px; font-size: 12.5px; }

/* chat layout */
#chat { display: grid; grid-template-columns: 240px 1fr; }
#sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
.side-head { padding: 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.side-head #me { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 4px; }
#room-list { padding: 10px; }
#room-list button {
  display: flex; justify-content: space-between; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 8px; border: 0; background: none; color: var(--text);
  cursor: pointer; font: inherit; margin-bottom: 2px;
}
#room-list button:hover { background: var(--panel2); }
#room-list button.active { background: var(--accent); color: #fff; }
#room-list .count { color: var(--muted); font-size: 12px; }
#room-list button.active .count { color: #ddd; }
#dm-list-wrap { padding: 10px; border-top: 1px solid var(--border); margin-top: auto; }
#dm-list-wrap h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 4px 6px 8px; }
#dm-list button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; margin-bottom: 2px;
  border-radius: 8px; border: 0; background: none; color: var(--text); cursor: pointer; font: inherit;
}
#dm-list button:hover { background: var(--panel2); }
#dm-list button.active { background: var(--panel2); font-weight: 600; }

/* main */
#main { display: flex; flex-direction: column; min-width: 0; }
#chat-header {
  display: flex; align-items: baseline; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
#room-title { font-weight: 700; font-size: 17px; }
#messages { flex: 1; overflow-y: auto; padding: 16px 20px; }
.msg { margin-bottom: 12px; max-width: 720px; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .meta .name { font-weight: 700; color: var(--accent2); }
.msg .body { background: var(--panel2); padding: 8px 12px; border-radius: 10px; word-wrap: break-word; white-space: pre-wrap; }
.msg.mine .body { background: var(--mine); }
.msg code { background: #0d0f14; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.msg .mention { color: var(--accent2); font-weight: 600; }
.msg .reactions { margin-top: 4px; display: flex; gap: 6px; }
.msg .react-btn {
  border: 1px solid var(--border); background: none; border-radius: 12px;
  padding: 1px 8px; cursor: pointer; font-size: 12px; color: var(--text);
}
.msg .react-btn.mine { border-color: var(--accent); }
#messages .day-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0; }
#composer { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--panel); }
#composer button { width: auto; padding: 10px 18px; }

@media (max-width: 640px) {
  #chat { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  #sidebar.open { display: flex; position: absolute; z-index: 5; height: 100vh; width: 240px; }
}
