:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
  background: #e7e9ec;
  color: #18202a;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(390px, 100%); background: #fff; border-radius: 18px;
  padding: 34px; box-shadow: 0 18px 60px rgb(30 40 55 / 16%);
}
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px;
  color: white; font-weight: 750; font-size: 24px;
  background: linear-gradient(145deg, #16b777, #087b57);
}
.login-card h1 { margin: 22px 0 5px; font-size: 26px; }
.login-card > p { margin: 0 0 24px; color: #77808b; }
.login-card label { display: grid; gap: 7px; margin: 15px 0; color: #4d5662; font-size: 14px; }
.login-card input {
  min-height: 44px; border: 1px solid #d7dbe0; border-radius: 9px; padding: 0 12px;
  outline: none;
}
.login-card input:focus { border-color: #18a96f; box-shadow: 0 0 0 3px rgb(24 169 111 / 12%); }
.login-card button {
  width: 100%; min-height: 44px; border: 0; border-radius: 9px; margin-top: 8px;
  background: #19ad72; color: white; font-weight: 650;
}
.login-card button:disabled { opacity: .55; cursor: wait; }
.admin-login-card .brand-mark { background: linear-gradient(145deg, #3578d4, #23539c); }
.admin-login-card input:focus { border-color: #3578d4; box-shadow: 0 0 0 3px rgb(53 120 212 / 12%); }
.admin-login-card #loginButton { background: #3578d4; }
.form-error { min-height: 20px; margin-top: 12px; color: #bd3630; font-size: 13px; }
.chat-shell {
  width: min(1120px, 100%); height: min(900px, calc(100vh - 40px)); min-height: 520px;
  display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden;
  background: #f4f5f6; border: 1px solid #d8dce1; border-radius: 14px;
  box-shadow: 0 20px 60px rgb(30 40 55 / 18%);
}
.chat-workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.admin-mode .chat-workspace { grid-template-columns: 280px minmax(0, 1fr); }
.chat-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-main .messages { flex: 1; min-height: 0; }
.chat-main .composer { flex: none; }
.conversation-title { padding: 12px 20px; background: #fafbfc; border-bottom: 1px solid #e2e5e8; font-size: 14px; }
.user-sidebar { display: flex; flex-direction: column; min-height: 0; background: #eef1f3; border-right: 1px solid #d8dce1; }
.user-search { display: flex; gap: 6px; padding: 12px; }
.user-search input { min-width: 0; width: 100%; padding: 8px; border: 1px solid #d7dbe0; border-radius: 6px; }
.user-list { flex: 1; min-height: 0; overflow: auto; }
.user-item { display: block; width: 100%; border: 0; border-bottom: 1px solid #e0e5e8; background: transparent; padding: 14px 16px; text-align: left; }
.user-item:hover { background: #e4ebe8; }
.user-item.selected { background: #d7ece0; box-shadow: inset 3px 0 #14a16a; }
.user-item strong, .user-item small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-item strong { font-size: 14px; }
.user-item small { margin-top: 5px; color: #77818a; font-size: 12px; }
.user-list-status { padding: 0 12px; font-size: 12px; color: #80786b; }
.official .avatar { background: #196ba7; }
.official .message-meta { color: #196ba7; }
.chat-header {
  min-height: 76px; padding: 14px 22px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; background: #fff; border-bottom: 1px solid #e2e5e8;
}
.chat-header h1 { font-size: 18px; margin: 0 0 4px; }
.chat-header p { font-size: 12px; color: #79828d; margin: 0; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.retention { color: #89919a; font-size: 12px; }
.ghost { border: 1px solid #d6dbe0; border-radius: 7px; background: #fff; padding: 7px 12px; }
.connection-state { padding: 7px 18px; text-align: center; color: #8a6425; background: #fff6d9; font-size: 12px; }
.messages { overflow: auto; padding: 28px clamp(18px, 5vw, 72px); scroll-behavior: smooth; }
.empty { color: #8a929b; text-align: center; margin: 22vh 0 0; }
.message-row { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 20px; }
.message-row.mine { flex-direction: row-reverse; }
.avatar {
  flex: 0 0 36px; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 8px; color: white; background: #76818e; font-size: 12px; font-weight: 650;
}
.mine .avatar { background: #18a96f; }
.message-column { max-width: min(72%, 680px); }
.message-meta { margin: 0 3px 5px; color: #929aa3; font-size: 11px; }
.mine .message-meta { text-align: right; }
.bubble {
  position: relative; padding: 10px 13px; border-radius: 6px; background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 7%); overflow-wrap: anywhere; white-space: pre-wrap;
}
.mine .bubble { background: #95ec69; }
.attachment-list { display: grid; gap: 7px; margin-top: 9px; }
.attachment {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px;
  min-width: 240px; padding: 9px; border: 1px solid rgb(0 0 0 / 8%); border-radius: 7px;
  color: inherit; background: rgb(255 255 255 / 58%); text-decoration: none;
}
.attachment-icon { font-size: 21px; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { color: #747d87; font-size: 11px; }
.pending .bubble { opacity: .68; }
.failed .bubble { border: 1px solid #db6b63; }
.retry { margin-top: 7px; border: 0; padding: 0; color: #c2352d; background: transparent; }
.composer { padding: 12px 16px 14px; background: #fff; border-top: 1px solid #dfe3e6; }
.composer-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.attach-button {
  height: 40px; min-width: 62px; display: flex; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid #d7dce0; border-radius: 8px; color: #4e5965; cursor: pointer;
}
.attach-button input { display: none; }
.attach-button span:first-of-type { font-size: 20px; }
.attach-text { font-size: 12px; }
#messageInput {
  width: 100%; min-height: 40px; max-height: 132px; resize: none; overflow-y: auto;
  border: 1px solid #d5dade; border-radius: 9px; padding: 9px 11px; outline: none;
}
#messageInput:focus { border-color: #27ad79; }
.send-button { height: 40px; border: 0; border-radius: 8px; padding: 0 20px; color: #fff; background: #1aad72; }
.send-button:disabled { opacity: .5; cursor: default; }
.file-list { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 10px 72px; }
.file-chip { flex: none; max-width: 240px; padding: 5px 8px; border-radius: 6px; background: #eef1f3; font-size: 12px; }
.file-chip button { border: 0; color: #8e3b35; background: transparent; }
.send-progress { height: 3px; margin-top: 9px; overflow: hidden; border-radius: 2px; background: #e5e8ea; }
.send-progress span { display: block; width: 0; height: 100%; background: #1aad72; transition: width .15s; }
@media (max-width: 640px) {
  .page { padding: 0; }
  .chat-shell { width: 100%; height: 100vh; border: 0; border-radius: 0; }
  .retention { display: none; }
  .messages { padding: 20px 12px; }
  .message-column { max-width: 82%; }
  .attach-text { display: none; }
  .attach-button { min-width: 42px; }
  .file-list { margin-left: 0; }
  .admin-mode .chat-workspace { grid-template-columns: 125px minmax(0, 1fr); }
  .admin-mode .user-search { padding: 7px; flex-direction: column; }
  .admin-mode .user-item { padding: 12px 8px; }
  .admin-mode .messages { padding: 14px 7px; }
  .admin-mode .message-column { max-width: 80%; }
  .admin-mode .attachment { min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .admin-mode .composer { padding: 8px; }
  .admin-mode .send-button { padding: 0 10px; }
}
