* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --bg: #f2f2f2;
  --sidebar: #2e2e2e;
  --bubble-self: #95ec69;
  --bubble-other: #ffffff;
  --text: #1a1a1a;
  --muted: #888;
}

html, body, #app { height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button { cursor: pointer; border: none; font: inherit; }
input { font: inherit; }

/* ---------- 登录 / 注册 ---------- */
.auth-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #07c160 0%, #06a04f 100%);
}
.auth-card {
  width: 340px; background: #fff; border-radius: 16px; padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card p.sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 12px; border: 1px solid #ddd; border-radius: 10px; outline: none;
}
.field input:focus { border-color: var(--green); }
.btn {
  width: 100%; padding: 12px; border-radius: 10px; background: var(--green); color: #fff;
  font-weight: 600; transition: background .15s;
}
.btn:hover { background: var(--green-dark); }
.btn.ghost { background: #f0f0f0; color: #333; margin-top: 10px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-switch a { color: var(--green); text-decoration: none; }
.error-msg { color: #d93025; font-size: 13px; min-height: 18px; margin-bottom: 10px; }

/* ---------- 主布局 ---------- */
.main { display: flex; height: 100%; }

.sidebar {
  width: 280px; background: var(--sidebar); color: #eee; display: flex; flex-direction: column;
}
.side-user {
  padding: 18px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #444;
}
.avatar {
  width: 42px; height: 42px; border-radius: 10px; background: var(--green);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff;
}
.side-user .name { font-weight: 600; }
.side-user .logout { margin-left: auto; font-size: 12px; color: #bbb; background: none; }
.side-user .logout:hover { color: #fff; }

.room-list { flex: 1; overflow-y: auto; padding: 8px; }
.room-item {
  padding: 13px 12px; border-radius: 10px; margin-bottom: 4px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.room-item:hover { background: #3d3d3d; }
.room-item.active { background: var(--green); }
.room-item .rname { font-weight: 600; }
.room-item .rtime { font-size: 11px; color: #bbb; }
.room-item.active .rtime { color: #eafff1; }

.side-footer { padding: 12px; }
.side-footer .btn { background: #444; }
.side-footer .btn:hover { background: #555; }

/* ---------- 聊天区 ---------- */
.chat { flex: 1; display: flex; flex-direction: column; }
.chat-header {
  height: 60px; background: #fff; border-bottom: 1px solid #eee; display: flex;
  align-items: center; padding: 0 22px; font-weight: 600;
}
.chat-header .hint { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 12px; }

.messages { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.msg-row { display: flex; gap: 10px; max-width: 70%; }
.msg-row.self { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .bubble {
  padding: 10px 13px; border-radius: 12px; line-height: 1.5; word-break: break-word;
  background: var(--bubble-other);
}
.msg-row.self .bubble { background: var(--bubble-self); }
.msg-row .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg-row.self .meta { text-align: right; }
.msg-row .nick { font-size: 12px; color: #666; margin-bottom: 4px; }

.composer {
  background: #fff; border-top: 1px solid #eee; padding: 14px 18px; display: flex; gap: 12px;
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid #ddd; border-radius: 10px; padding: 11px 12px; height: 46px; outline: none;
}
.composer textarea:focus { border-color: var(--green); }
.composer .send { padding: 0 22px; border-radius: 10px; background: var(--green); color: #fff; font-weight: 600; }
.composer .send:disabled { background: #ccc; cursor: not-allowed; }

.empty {
  margin: auto; text-align: center; color: var(--muted);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center;
  justify-content: center; z-index: 20;
}
.modal { width: 340px; background: #fff; border-radius: 16px; padding: 26px 24px; }
.modal h2 { font-size: 18px; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; margin-top: 20px; }
.modal .actions .btn { width: 50%; }
.modal .btn.ghost { background: #f0f0f0; color: #333; }
