:root {
  --bg: #111214;
  --bg2: #18191c;
  --bg3: #202226;
  --border: #2a2c31;
  --text: #e6e6e6;
  --muted: #9aa0a6;
  --accent: #4f8cff;
  --accent-hover: #3b76e0;
  --danger: #e05555;
  --radius: 6px;
  --gap: 8px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
button { background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; cursor: pointer; font: inherit; }
button:hover { background: #26282d; }
button.primary, form button[type=submit] { background: var(--accent); border-color: var(--accent); color: #fff; }
form button[type=submit]:hover { background: var(--accent-hover); }
input { background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; font: inherit; width: 100%; }
input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.err { color: var(--danger); font-size: 12px; min-height: 14px; margin: 4px 0 0; }

.auth { display: flex; align-items: center; justify-content: center; height: 100%; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 320px; max-width: 90vw; }
.card h1 { margin: 0 0 16px; font-size: 18px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; background: var(--bg3); }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
form { display: flex; flex-direction: column; gap: var(--gap); }
.hidden { display: none !important; }

.app { display: flex; height: 100%; }
.sidebar { width: 260px; min-width: 200px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 10px; gap: var(--gap); overflow-y: auto; }
.me { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.small { padding: 4px 8px; font-size: 12px; }
.search input { margin-bottom: 4px; }
.section { font-size: 11px; text-transform: uppercase; color: var(--muted); margin-top: 8px; letter-spacing: 0.5px; }
.list { display: flex; flex-direction: column; gap: 2px; }
.item { padding: 6px 8px; border-radius: var(--radius); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.item:hover { background: var(--bg3); }
.item.active { background: var(--bg3); border-left: 2px solid var(--accent); }
.item .name { flex: 1; }
.item .badge { background: var(--accent); color: #fff; border-radius: 10px; font-size: 10px; line-height: 1; padding: 2px 6px; margin-left: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #555; display: inline-block; margin-left: 6px; }
.dot.on { background: #4caf50; }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chatHeader { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg2); }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 75%; padding: 6px 10px; border-radius: var(--radius); background: var(--bg3); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; }
.msg.mine { background: var(--accent); color: #fff; align-self: flex-end; }
.msg .meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.msg.mine .meta { color: rgba(255,255,255,0.7); }
.composer { display: flex; flex-direction: row; align-items: center; gap: var(--gap); padding: 10px; border-top: 1px solid var(--border); background: var(--bg2); }
.composer input { flex: 1 1 auto; min-width: 0; }
.composer button { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 700px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
  .chat { height: 60%; }
}
