/* ===== 轻聊 · 主题 ===== */
:root {
  --bg: #080e14;
  --panel: #0f1720;
  --panel-2: #131e27;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8f1f6;
  --text-dim: #8ba0ad;
  --accent: #34d399;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --radius: 16px;
  --font: "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; }
.hidden { display: none !important; }

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 12% 8%, rgba(52, 211, 153, 0.16), transparent 70%),
    radial-gradient(55% 45% at 88% 92%, rgba(34, 211, 238, 0.13), transparent 70%);
}

/* ===== 通用控件 ===== */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s ease, filter .2s ease, background .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #04231d;
  font-weight: 700;
}
.btn.ghost { background: transparent; }
.btn.block { width: 100%; justify-content: center; padding: 13px 18px; font-size: 15px; }
.btn.tiny { padding: 6px 12px; font-size: 12px; border-radius: 10px; }

.icon-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  width: 36px; height: 36px;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.icon-btn.danger { color: #f8877f; border-color: rgba(248, 113, 113, .25); background: rgba(248, 113, 113, .08); }
.icon-btn.danger:hover { color: #ffb4ae; background: rgba(248, 113, 113, .18); border-color: rgba(248, 113, 113, .45); }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: .3px;
}
.field > span em { font-style: normal; color: #5f7482; }
.field input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus {
  border-color: rgba(52, 211, 153, .55);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .12);
}
.field input::placeholder { color: #5f7482; }

.error { color: var(--danger); font-size: 13px; margin: 0 0 12px; min-height: 0; }

/* ===== 登录页 ===== */
.auth-view {
  position: relative;
  height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: rgba(15, 23, 32, .93);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 24px 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
  animation: pop .35s cubic-bezier(.2, .8, .25, 1);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.brand { display: flex; gap: 13px; align-items: center; margin-bottom: 22px; }
.brand-mark {
  width: 46px; height: 46px; flex: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04231d;
  font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(52, 211, 153, .25);
}
.brand-mark.small { width: 34px; height: 34px; font-size: 17px; border-radius: 11px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 1px; }
.brand p { margin: 3px 0 0; font-size: 12px; color: var(--text-dim); }

.tabs {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  padding: 9px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: all .22s;
}
.tab.active {
  background: rgba(52, 211, 153, .14);
  color: var(--accent);
  font-weight: 600;
}
.auth-tip {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== 主界面 ===== */
.main-view {
  height: 100dvh;
  display: flex;
  position: relative;
}

/* 侧边栏 */
.sidebar {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: rgba(11, 18, 25, .9);
  border-right: 1px solid var(--line);
  padding: 14px 14px 8px;
  gap: 12px;
}
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-brand { display: flex; align-items: center; gap: 10px; }
.side-title { font-size: 16px; font-weight: 700; letter-spacing: 1px; }
.side-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.me-chip {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.avatar {
  width: 36px; height: 36px; flex: none;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  color: #04231d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  text-transform: uppercase;
}
.me-name { font-size: 14px; font-weight: 600; }
.me-state { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.rooms-bar {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-dim);
  padding: 2px 2px 0;
}
.rooms-bar .btn.tiny svg { color: var(--accent); }

.room-list {
  list-style: none;
  margin: 0; padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 8px;
}
.room-list::-webkit-scrollbar { width: 6px; }
.room-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 6px; }

.room-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1px solid transparent;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .12s;
}
.room-item:hover { background: rgba(255,255,255,.07); }
.room-item:active { transform: scale(.99); }
.room-item.active {
  background: rgba(52, 211, 153, .1);
  border-color: rgba(52, 211, 153, .35);
}
.room-icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  background: rgba(34, 211, 238, .12);
  color: var(--accent-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.room-main { min-width: 0; flex: 1; }
.room-name {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 5px;
}
.room-meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.unread {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #04231d;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.empty-tip {
  font-size: 12px; color: #5f7482; text-align: center;
  padding: 24px 10px;
}

/* 聊天区 */
.chat-pane { flex: 1; min-width: 0; position: relative; display: flex; }
.chat-empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.chat-empty-inner { text-align: center; max-width: 320px; }
.big-mark {
  width: 74px; height: 74px; margin: 0 auto 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04231d;
  font-size: 34px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 18px 40px rgba(52, 211, 153, .22);
}
.chat-empty-inner h2 { font-size: 18px; margin: 0 0 8px; }
.chat-empty-inner p { font-size: 13px; color: var(--text-dim); margin: 0 0 20px; line-height: 1.6; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 25, .96);
}
.chat-head .back { display: none; }
.chat-title { flex: 1; min-width: 0; }
.chat-title h3 {
  margin: 0; font-size: 16px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-sub { font-size: 11px; color: var(--text-dim); }
.badge {
  font-size: 11px; padding: 4px 9px; border-radius: 8px;
  background: rgba(251, 191, 36, .12);
  color: #fbbf24;
  white-space: nowrap;
}

/* 消息列表 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 14px;
  overscroll-behavior: contain;
}
.messages::-webkit-scrollbar { width: 7px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 7px; }

.msg { display: flex; gap: 9px; max-width: 78%; }
.msg .avatar { width: 30px; height: 30px; font-size: 13px; border-radius: 10px; }
.msg-body { min-width: 0; }
.msg-head {
  font-size: 11px; color: var(--text-dim);
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 4px;
}
.msg-name { font-weight: 600; color: #b9cbd6; }
.msg-bubble {
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  padding: 9px 13px;
  border-radius: 4px 13px 13px 13px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .msg-head { justify-content: flex-end; }
.msg.mine .msg-bubble {
  background: linear-gradient(135deg, rgba(52, 211, 153, .2), rgba(34, 211, 238, .16));
  border-color: rgba(52, 211, 153, .3);
  border-radius: 13px 4px 13px 13px;
  color: #eafff8;
}
.msg.mine .msg-name { color: var(--accent); }

/* 管理员消息：金色标识 */
.msg .avatar.admin-av {
  background: linear-gradient(135deg, #f9d97b, #e0a23a);
  color: #3a2600;
  box-shadow: 0 0 0 1px rgba(246, 196, 83, .45), 0 6px 16px rgba(224, 162, 58, .28);
}
.msg.admin .msg-name {
  color: #f6c453;
  font-weight: 700;
  letter-spacing: .01em;
  text-shadow: 0 0 14px rgba(246, 196, 83, .35);
}
.msg.admin .msg-bubble {
  background: linear-gradient(135deg, rgba(246, 196, 83, .16), rgba(246, 196, 83, .05));
  border-color: rgba(246, 196, 83, .38);
  color: #fdf3dd;
}
.admin-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 1px 6px;
  border-radius: 6px;
  color: #3a2600;
  background: linear-gradient(135deg, #f9d97b, #e6ad46);
  box-shadow: 0 2px 8px rgba(230, 173, 70, .25);
}
.sys-msg {
  align-self: center;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, .04);
  padding: 5px 12px;
  border-radius: 20px;
}

.typing-bar {
  height: 18px;
  padding: 0 18px;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity .2s;
}
.typing-bar.show { opacity: 1; }

/* 输入框 */
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(11, 18, 25, .97);
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  padding: 11px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.composer textarea:focus {
  border-color: rgba(52, 211, 153, .5);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .1);
}
.composer textarea::placeholder { color: #5f7482; }
.send-btn {
  width: 44px; height: 44px; flex: none;
  border: none; border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04231d;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, filter .2s;
}
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 8, 12, .84);
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 360px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .5);
  animation: pop .26s cubic-bezier(.2, .8, .25, 1);
}
.modal-card h3 { margin: 0 0 6px; font-size: 17px; }
.modal-sub { margin: 0 0 16px; font-size: 13px; color: var(--text-dim); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(20, 30, 38, .95);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 60;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 手机端：单栏切换 ===== */
@media (max-width: 860px) {
  .sidebar {
    width: 100%;
    border-right: none;
    padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
    gap: 10px;
  }
  .side-title { font-size: 17px; }
  .me-chip { border-radius: 15px; }
  .room-list { gap: 9px; }
  .room-item { padding: 13px 12px; border-radius: 15px; }
  .room-icon { width: 38px; height: 38px; border-radius: 12px; font-size: 16px; }
  .room-name { font-size: 15px; }
  .room-meta { font-size: 11.5px; margin-top: 4px; }
  .unread { min-width: 20px; height: 20px; border-radius: 10px; font-size: 11.5px; }

  .chat-pane { position: absolute; inset: 0; z-index: 10; background: var(--bg); display: none; }
  .main-view.chat-open .chat-pane { display: flex; }
  .main-view.chat-open .sidebar { visibility: hidden; }

  .chat-head { padding: calc(8px + env(safe-area-inset-top)) 12px 10px; gap: 10px; }
  .chat-head .back { display: inline-flex; width: 38px; height: 38px; border-radius: 12px; }
  .chat-title h3 { font-size: 16.5px; }
  .chat-sub { font-size: 11.5px; }
  .badge { font-size: 10.5px; padding: 3px 8px; }

  .messages { padding: 14px 12px 8px; gap: 16px; }
  .msg { max-width: 88%; gap: 8px; }
  .msg .avatar { width: 32px; height: 32px; font-size: 13.5px; border-radius: 11px; }
  .msg-head { font-size: 11.5px; margin-bottom: 5px; }
  .msg-name { font-size: 12px; }
  .msg-bubble {
    font-size: 15px;
    line-height: 1.6;
    padding: 10px 14px;
    border-radius: 5px 15px 15px 15px;
  }
  .msg.mine .msg-bubble { border-radius: 15px 5px 15px 15px; }
  .sys-msg { font-size: 11.5px; padding: 5px 14px; }
  .typing-bar { padding: 0 14px; }
  .big-mark { width: 62px; height: 62px; font-size: 28px; border-radius: 18px; margin-bottom: 14px; }
  .chat-empty-inner h2 { font-size: 17px; }

  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .composer textarea {
    font-size: 16px; /* 避免 iOS 聚焦时放大整页 */
    min-height: 44px;
    padding: 11px 15px;
    border-radius: 20px;
    max-height: 108px;
  }
  .send-btn { width: 46px; height: 46px; border-radius: 50%; }

  .auth-view {
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  }
  .auth-card { border-radius: 20px; padding: 22px 18px 18px; }
  .brand h1 { font-size: 19px; }
  .field input { font-size: 16px; padding: 12px 14px; }
  .btn.block { padding: 14px 18px; border-radius: 14px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card { max-width: none; border-radius: 20px 20px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); animation: slideUp .26s ease; }
  @keyframes slideUp { from { transform: translateY(30%); } to { transform: none; } }
}

/* 触屏按下反馈更自然，避免长按选中文字 */
@media (hover: none) {
  .room-item:hover { background: rgba(255, 255, 255, .03); }
  .room-item:active { background: rgba(255, 255, 255, .08); }
  .btn:active, .icon-btn:active { filter: brightness(1.15); }
}

