* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f5; color: #191919; font-size: 14px; overflow: hidden;
}
button, input, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; }

/* ---------- 登录 / 注册 ---------- */
.auth-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #07c160 0%, #06ad56 45%, #0b8f6a 100%); padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 12px; background: #07c160;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px;
}
.brand-name { font-size: 24px; font-weight: 600; letter-spacing: 2px; }
.auth-tabs { display: flex; border-bottom: 1px solid #eee; margin-bottom: 22px; }
.auth-tabs button { flex: 1; padding: 10px 0 12px; color: #888; font-size: 15px; position: relative; }
.auth-tabs button.active { color: #07c160; font-weight: 600; }
.auth-tabs button.active::after {
  content: ""; position: absolute; left: 25%; right: 25%; bottom: -1px; height: 2px; background: #07c160; border-radius: 2px;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: #888; margin-bottom: 7px; }
.field input {
  width: 100%; height: 42px; border: 1px solid #e2e2e2; border-radius: 8px; padding: 0 12px; outline: none; background: #fafafa;
}
.field input:focus { border-color: #07c160; background: #fff; }
.primary-btn {
  width: 100%; height: 44px; border-radius: 8px; background: #07c160; color: #fff; font-size: 15px; font-weight: 600; margin-top: 6px;
}
.primary-btn:active { background: #06ad56; }
.primary-btn:disabled { opacity: .5; }
.auth-msg { min-height: 20px; margin-top: 12px; text-align: center; color: #e64340; font-size: 13px; }

/* ---------- 主界面 ---------- */
.app-screen { display: none; height: 100%; }
.app-screen.visible { display: flex; }

.sidebar {
  width: 62px; flex: none; background: #2e2e2e; display: flex; flex-direction: column; align-items: center;
  padding: 22px 0 16px; gap: 26px;
}
.side-avatar { width: 38px; height: 38px; border-radius: 6px; background: #4a4a4a; }
.side-icons { display: flex; flex-direction: column; gap: 18px; flex: 1; }
.side-btn {
  width: 38px; height: 38px; border-radius: 6px; color: #8f8f8f; font-size: 20px;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.side-btn.active, .side-btn:hover { color: #07c160; background: #3a3a3a; }
.side-badge {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #fa5151; color: #fff; font-size: 10px; line-height: 16px; text-align: center;
}

.list-panel { width: 280px; flex: none; background: #f7f7f7; border-right: 1px solid #e3e3e3; display: flex; flex-direction: column; }
.list-header {
  height: 58px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  font-size: 16px; font-weight: 600;
}
.icon-btn { width: 30px; height: 30px; border-radius: 6px; font-size: 20px; color: #555; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #e8e8e8; }
.search-box { padding: 0 12px 10px; }
.search-box input {
  width: 100%; height: 32px; border: none; border-radius: 6px; background: #eaeaea; padding: 0 10px; outline: none; font-size: 13px;
}
.list-scroll { flex: 1; overflow-y: auto; }
.list-scroll.hidden { display: none; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; position: relative;
}
.list-item:hover, .list-item.active { background: #e9e9e9; }
.avatar {
  position: relative;
  width: 42px; height: 42px; flex: none; border-radius: 5px; object-fit: cover;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 17px; font-weight: 500;
}
.avatar.online::after {
  content: ""; position: absolute; width: 9px; height: 9px; border-radius: 50%; background: #07c160;
  border: 2px solid #f7f7f7; margin: 26px 0 0 30px;
}
.item-main { flex: 1; min-width: 0; }
.item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.item-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 11px; color: #b2b2b2; flex: none; }
.item-desc { font-size: 12px; color: #999; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  position: absolute; right: 14px; top: 32px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #fa5151; color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.empty { text-align: center; color: #bbb; font-size: 13px; padding: 46px 20px; line-height: 1.9; }

.chat-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #f5f5f5; }
.chat-header {
  height: 58px; flex: none; background: #f7f7f7; border-bottom: 1px solid #e3e3e3;
  display: flex; align-items: center; padding: 0 18px; gap: 10px; font-size: 16px; font-weight: 600;
}
.chat-header .back-btn { display: none; font-size: 28px; line-height: 1; padding: 0 4px; }
.chat-header .icon-btn { margin-left: auto; }
.messages { flex: 1; overflow-y: auto; padding: 18px 20px; }
.msg-row { display: flex; gap: 10px; margin-bottom: 18px; align-items: flex-start; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-row .avatar { width: 36px; height: 36px; font-size: 14px; }
.msg-wrap { max-width: 68%; }
.msg-name { font-size: 11px; color: #999; margin: 0 0 4px 2px; }
.msg-row.mine .msg-name { text-align: right; margin-right: 2px; }
.bubble {
  background: #fff; padding: 9px 12px; border-radius: 4px; line-height: 1.6; word-break: break-word;
  white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.04); position: relative; font-size: 14px;
}
.bubble::before {
  content: ""; position: absolute; left: -5px; top: 12px; width: 0; height: 0;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-right: 5px solid #fff;
}
.msg-row.mine .bubble { background: #95ec69; }
.msg-row.mine .bubble::before { left: auto; right: -5px; border-right: none; border-left: 5px solid #95ec69; }
.bubble img { max-width: 100%; border-radius: 4px; }
.composer { flex: none; border-top: 1px solid #e3e3e3; background: #f7f7f7; padding-bottom: env(safe-area-inset-bottom); }
.emoji-bar { display: flex; gap: 4px; padding: 7px 14px 0; overflow-x: auto; }
.emoji-bar button { font-size: 19px; padding: 2px 4px; border-radius: 4px; }
.emoji-bar button:hover { background: #e8e8e8; }
.composer-input { display: flex; gap: 10px; padding: 8px 14px 12px; align-items: flex-end; }
.composer textarea {
  flex: 1; height: 62px; resize: none; border: none; border-radius: 6px; background: #fff; padding: 9px 10px; outline: none; line-height: 1.5;
}
.send-btn { height: 34px; padding: 0 18px; border-radius: 5px; background: #07c160; color: #fff; font-weight: 500; }
.send-btn:disabled { background: #b9e5c9; }

/* ---------- 弹窗 / 提示 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.42); display: none; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal.visible { display: flex; }
.modal-card {
  width: 100%; max-width: 420px; max-height: 82vh; overflow-y: auto; background: #fff; border-radius: 12px; padding: 20px;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal-close { font-size: 22px; color: #999; line-height: 1; }
.modal .field { margin-bottom: 12px; }
.modal .primary-btn { margin-top: 8px; }
.result-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f2f2f2; }
.result-item .item-main { flex: 1; }
.mini-btn { padding: 5px 12px; border-radius: 5px; background: #07c160; color: #fff; font-size: 12px; }
.mini-btn.ghost { background: #eee; color: #555; }
.section-label { font-size: 12px; color: #999; margin: 16px 0 6px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid #f2f2f2; }
.switch-row input[type=checkbox] { width: 18px; height: 18px; accent-color: #07c160; }
.toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%) translateY(-20px); background: rgba(0,0,0,.8); color: #fff;
  padding: 9px 18px; border-radius: 6px; font-size: 13px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 100; max-width: 80vw; text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 移动端适配 ---------- */
@media (max-width: 767px) {
  .app-screen.visible { display: block; position: relative; }
  .sidebar { display: none; }
  .list-panel { width: 100%; height: 100%; border-right: none; }
  .list-header { height: 52px; padding-top: env(safe-area-inset-top); }
  .chat-panel { display: none; position: absolute; inset: 0; z-index: 10; }
  .app-screen.show-chat .list-panel { display: none; }
  .app-screen.show-chat .chat-panel { display: flex; }
  .chat-header { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
  .chat-header .back-btn { display: block; }
  .messages { padding: 14px 12px; }
  .msg-wrap { max-width: 76%; }
  .auth-card { padding: 26px 22px; }
}
