:root {
  --bg: #f4f5f7;
  --fg: #1d1f23;
  --accent: #2f6feb;
  --bubble-own: #d1e7ff;
  --bubble-other: #ffffff;
  --chat-bg: #f4f5f7;
  --font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--fg);
  display: flex; flex-direction: column; height: 100vh; font-size: var(--font-size);
}
#topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 20px; background: #222; color: #fff;
}
#topbar nav a {
  color: #bbb; text-decoration: none; padding: 6px 10px;
  border-radius: 6px; margin-right: 8px; transition: all .15s;
}
#topbar nav a.active, #topbar nav a:hover { color: #fff; background: #444; }
#user-info { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-block; }

#app { flex: 1; overflow-y: auto; padding: 20px; }
h2 { margin-top: 0; }

/* ============ TOASTS ============ */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--toast-bg, #2b2f36);
  color: var(--toast-fg, #fff);
  padding: 12px 16px; border-radius: 8px;
  background: #2b2f36; color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  font-size: 14px; border-left: 4px solid var(--accent);
  cursor: pointer; word-wrap: break-word;
  opacity: 0; transform: translateX(120%);
  transition: transform .25s ease, opacity .25s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.hide { opacity: 0; transform: translateX(120%); }
.toast-success { border-left-color: #27ae60; }
.toast-error { border-left-color: #c0392b; }
.toast-warn { border-left-color: #f39c12; }
.toast-info { border-left-color: var(--accent); }

/* ============ BUTTONS & FORMS ============ */
.btn {
  padding: 10px 16px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; transition: opacity .15s;
}
.btn:hover { opacity: .9; }
.btn-secondary { background: #555; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: .9em; color: #555; }
.form-row input, .form-row select {
  padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font: inherit;
}

/* ============ LOGIN ============ */
.login-box {
  max-width: 400px; margin: 60px auto; padding: 24px;
  background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* ============ CHATS LIST ============ */
.chat-list { display: flex; flex-direction: column; gap: 8px; }
.chat-item {
  padding: 14px 18px; background: #fff; border-radius: 10px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); transition: background .15s;
}
.chat-item:hover { background: #eef4ff; }
.chat-item .meta { color: #888; font-size: .85em; margin-top: 4px; }

/* ============ CHAT VIEW ============ */
.chat-view { display: flex; flex-direction: column; height: calc(100vh - 100px); }
.chat-header { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.chat-header h2 { margin: 0; }
.chat-messages {
  flex: 1; overflow-y: auto; background: var(--chat-bg);
  padding: 12px; border-radius: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.msg { max-width: 70%; padding: 8px 12px; border-radius: 12px; word-wrap: break-word; }
.msg.own { align-self: flex-end; background: var(--bubble-own); }
.msg.other { align-self: flex-start; background: var(--bubble-other); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.msg .time { font-size: .72em; color: #777; margin-left: 8px; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.chat-input textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 140px;
  padding: 10px; border-radius: 8px; border: 1px solid #ccc; font: inherit;
}
.btn svg {
  vertical-align: middle;
}
.moderator-only { display: none; }
body.is-moderator .moderator-only { display: inline-block; }
.msg .msg-actions { display: none; }
.msg:hover .msg-actions { display: flex !important; }
.sender-name { font-weight: 600; }
#reply-preview { margin-bottom: 6px; }
#mute-banner { margin-bottom: 6px; }
#emoji-picker { user-select: none; }
#emoji-picker span:hover { background: #f0f0f0; border-radius: 4px; }