:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f0f3f9;
  --line: #dce2ee;
  --text: #1c2434;
  --muted: #6b7590;
  --primary: #3457d5;
  --primary-strong: #243fa8;
  --accent: #16a085;
  --danger: #d64545;
  --shadow: 0 16px 40px rgba(28, 36, 52, 0.1);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(52, 87, 213, 0.12), transparent 30%),
    radial-gradient(circle at 88% 85%, rgba(22, 160, 133, 0.1), transparent 28%),
    var(--bg);
}

button, input { font: inherit; }

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

button:hover { background: var(--primary-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.secondary {
  color: var(--primary);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

button.secondary:hover { background: #e7ecf7; }

button.wechat {
  width: 100%;
  color: #fff;
  background: #07a85a;
}

button.wechat:hover { background: #068b4a; }

button.logout {
  margin-top: auto;
  color: var(--danger);
  background: transparent;
  border: 1px solid rgba(214, 69, 69, 0.35);
}

button.logout:hover { background: rgba(214, 69, 69, 0.08); }

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(52, 87, 213, 0.12);
}

.hidden { display: none !important; }

.center-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

.center-screen h1 { margin: 8px 0 0; color: var(--text); }
.center-screen p { margin: 0; }

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #6a7ff0);
  box-shadow: 0 12px 28px rgba(52, 87, 213, 0.3);
}

.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 21px; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 { margin: 0 0 8px; font-size: 26px; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-row h1 { margin: 0; font-size: 22px; }
.brand-row p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.form-block { margin-bottom: 16px; }
.form-block label, .side-section label, .group-composer label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.form-block button { margin-top: 10px; width: 100%; }

.form-message { min-height: 20px; margin: 6px 0 0; color: var(--danger); font-size: 13px; }
.form-message.ok { color: var(--accent); }

.subtle { color: var(--muted); font-size: 13px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.hint { margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--line);
}

.me-card {
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.me-name { font-weight: 700; }
.me-id { margin-top: 4px; color: var(--muted); font-size: 12px; }

.nav { display: grid; gap: 8px; }

.nav-btn {
  text-align: left;
  color: var(--muted);
  background: transparent;
}

.nav-btn:hover { background: var(--surface-soft); color: var(--text); }
.nav-btn.active { color: #fff; background: var(--primary); }

.side-section .inline { display: flex; gap: 8px; }
.side-section .inline input { min-width: 0; }
.side-section .inline button { flex: 0 0 auto; padding: 10px 12px; }

.workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  background: rgba(255, 255, 255, 0.75);
}

.list-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.panel-head {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2, .chat-head h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 5px 0 0; }

.group-composer {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.group-composer input { margin-bottom: 10px; }
.group-composer button { width: 100%; }

.member-checks {
  max-height: 150px;
  overflow: auto;
  margin-bottom: 10px;
  display: grid;
  gap: 6px;
}

.member-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
}

.member-checks input { width: auto; }

.item-list { flex: 1; overflow: auto; padding: 12px; }

.item {
  width: 100%;
  margin-bottom: 8px;
  padding: 13px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
}

.item:hover { background: var(--surface-soft); border-color: var(--line); }

.item-title { font-weight: 700; }
.item-sub { margin-top: 4px; color: var(--muted); font-size: 12px; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.item-actions button { padding: 7px 10px; font-size: 12px; }
.item-actions button.secondary { color: var(--primary); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.chat-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat-head .back {
  color: var(--muted);
  background: var(--surface-soft);
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 22px;
}

.message {
  max-width: 72%;
  margin-bottom: 14px;
  padding: 10px 13px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(28, 36, 52, 0.05);
}

.message.mine {
  margin-left: auto;
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.message-meta { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.message.mine .message-meta { color: rgba(255, 255, 255, 0.78); }
.message-body { white-space: pre-wrap; word-break: break-word; }

.message-form {
  display: flex;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.message-form input { flex: 1; }

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  color: #fff;
  background: #26324a;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error { background: var(--danger); }
.toast.ok { background: var(--accent); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .list-panel { border-right: 0; }
  .chat-pane { position: fixed; inset: 0; z-index: 10; background: var(--bg); }
}
