/* ==========================================================================
   聊一聊 · 样式
   ========================================================================== */

:root {
  --bg: #070b14;
  --panel: rgba(17, 25, 44, 0.92);
  --panel-2: #131d34;
  --panel-3: #182444;
  --line: rgba(126, 150, 205, 0.16);
  --line-strong: rgba(126, 150, 205, 0.28);
  --text: #e9eefb;
  --muted: #8b9bc0;
  --muted-2: #63739a;
  --accent: #6d8cff;
  --accent-2: #9a6dff;
  --green: #35d6a0;
  --danger: #ff7185;
  --amber: #ffc266;
  --bubble: #1b2747;
  --bubble-own: linear-gradient(135deg, #5f7dff 0%, #8b63ff 100%);
  --radius: 22px;
  --shadow: 0 24px 60px rgba(2, 6, 20, 0.55);
  --hover: rgba(255, 255, 255, 0.06);
  --soft: rgba(255, 255, 255, 0.04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 8% -12%, rgba(109, 140, 255, 0.28), transparent 62%),
    radial-gradient(900px 520px at 100% 0%, rgba(154, 109, 255, 0.2), transparent 58%),
    radial-gradient(700px 500px at 50% 120%, rgba(53, 214, 160, 0.08), transparent 60%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
a { color: #9db4ff; text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: rgba(140, 160, 210, 0.22);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(140, 160, 210, 0.36); }
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------------
   通用控件
   -------------------------------------------------------------------------- */

.primary {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 20px rgba(109, 140, 255, 0.28);
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.65; cursor: default; }
.primary.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

.ghost {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text);
}
.ghost:hover { background: rgba(255, 255, 255, 0.07); }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }

input[type="text"], input:not([type]), textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(10, 16, 30, 0.7);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  resize: none;
}
input:focus, textarea:focus {
  border-color: rgba(109, 140, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(109, 140, 255, 0.16);
}
::placeholder { color: var(--muted-2); }

/* 头像 */
.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  position: relative;
  background: linear-gradient(135deg, #4f6cf0, #7b57f0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  user-select: none;
}
.avatar.small { width: 38px; height: 38px; border-radius: 12px; font-size: 15px; }

.c-indigo  { background: linear-gradient(135deg, #4f6cf0, #7b57f0); }
.c-violet  { background: linear-gradient(135deg, #8a5cf6, #c05cf0); }
.c-teal    { background: linear-gradient(135deg, #12b692, #2ad2c0); }
.c-amber   { background: linear-gradient(135deg, #e8a13c, #f7c95c); }
.c-rose    { background: linear-gradient(135deg, #ef5f8c, #f78fb1); }
.c-sky     { background: linear-gradient(135deg, #2f9df0, #59c3f7); }
.c-lime    { background: linear-gradient(135deg, #6cbf3f, #a5d95c); }
.c-fuchsia { background: linear-gradient(135deg, #b93ff0, #e05ef7); }

.online-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #101a30;
  box-shadow: 0 0 8px rgba(53, 214, 160, 0.8);
}

/* --------------------------------------------------------------------------
   登录页
   -------------------------------------------------------------------------- */

.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(400px, 100%);
  padding: 36px 32px 28px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(24, 34, 60, 0.94), rgba(13, 20, 38, 0.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.login-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 16px 36px rgba(109, 140, 255, 0.4);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: 2px;
}

.login-card form {
  margin-top: 24px;
  display: grid;
  gap: 12px;
}

.login-hint {
  margin: 18px 0 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted-2);
}

.block { width: 100%; }

/* --------------------------------------------------------------------------
   主布局
   -------------------------------------------------------------------------- */

.app {
  height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: 328px minmax(0, 1fr);
  gap: 16px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.me {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.me-meta { min-width: 0; flex: 1; }
.me-name {
  font-weight: 650;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-status {
  font-size: 12px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 6px;
}
.me-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.sidebar-actions { padding: 12px 16px 6px; }

.list-title {
  padding: 12px 20px 8px;
  font-size: 11.5px;
  letter-spacing: 1.5px;
  color: var(--muted-2);
  text-transform: uppercase;
}

.conv-list {
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  padding: 0 10px 10px;
}

.conv-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}
.conv-item:hover { background: rgba(255, 255, 255, 0.045); }
.conv-item.active {
  background: linear-gradient(135deg, rgba(109, 140, 255, 0.2), rgba(154, 109, 255, 0.12));
  box-shadow: inset 0 0 0 1px rgba(120, 150, 255, 0.3);
}

.conv-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.conv-row { display: flex; align-items: center; gap: 8px; }
.conv-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-time { font-size: 11px; color: var(--muted-2); flex: 0 0 auto; }
.conv-preview {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.unread {
  flex: 0 0 auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff6b81, #ff8f6b);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(255, 107, 129, 0.4);
}

.request-list {
  max-height: 34vh;
  overflow-y: auto;
  padding: 0 10px 14px;
  display: grid;
  gap: 8px;
}
.request-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.request-item .avatar { width: 34px; height: 34px; border-radius: 11px; font-size: 13px; }
.request-body { flex: 1; min-width: 0; }
.request-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.request-sub { font-size: 11.5px; color: var(--muted-2); }
.request-actions { display: flex; gap: 6px; }
.mini {
  border-radius: 9px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: transparent;
}
.mini.primary { border: 0; }

/* --------------------------------------------------------------------------
   聊天区
   -------------------------------------------------------------------------- */

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent);
}
.chat-title { flex: 1; min-width: 0; }
.chat-title .name {
  font-size: 15.5px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-title .sub { font-size: 12px; color: var(--green); }
.chat-title .sub.offline { color: var(--muted-2); }

.back-btn { display: none; font-size: 26px; width: 32px; height: 32px; }

.conn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted-2);
  display: inline-block;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.conn-dot.ok { background: var(--green); box-shadow: 0 0 10px rgba(53, 214, 160, 0.85); }
.conn-dot.bad { background: var(--amber); box-shadow: 0 0 10px rgba(255, 194, 102, 0.8); }

/* 消息列表 */
.messages {
  overflow-y: auto;
  padding: 20px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-image:
    radial-gradient(rgba(140, 160, 220, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
}

.day-sep {
  align-self: center;
  margin: 14px 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(12, 19, 35, 0.75);
  border: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 11.5px;
  letter-spacing: 0.5px;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 3px 0;
  max-width: 100%;
  animation: msgIn 0.22s ease both;
}
.msg.own { flex-direction: row-reverse; }
.msg.grouped { padding-top: 0; }
.msg.grouped .avatar { visibility: hidden; height: 0; }

.msg-main { max-width: min(66%, 620px); display: flex; flex-direction: column; gap: 4px; }
.msg.own .msg-main { align-items: flex-end; }

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--muted-2);
}
.msg-name { color: var(--muted); font-weight: 600; }
.msg.own .msg-head { flex-direction: row-reverse; }

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  border-top-left-radius: 6px;
  background: var(--bubble);
  border: 1px solid var(--line);
  color: var(--text);
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 14px;
}
.msg.own .bubble {
  background: var(--bubble-own);
  border: 0;
  border-top-left-radius: 16px;
  border-top-right-radius: 6px;
  color: #fff;
  box-shadow: 0 10px 24px rgba(109, 140, 255, 0.26);
}
.bubble a { color: #bcd0ff; text-decoration: underline; text-underline-offset: 2px; }
.bubble a:hover { color: #fff; }

.bubble.media {
  padding: 6px;
  background: rgba(10, 16, 30, 0.55);
  border: 1px solid var(--line);
}
.msg.own .bubble.media { background: rgba(10, 16, 30, 0.55); box-shadow: none; }

.img-wrap { display: block; max-width: 320px; }
.msg-image {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  cursor: zoom-in;
  object-fit: contain;
  background: #0a1120;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
  max-width: 330px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
.file-ico {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: rgba(109, 140, 255, 0.16);
}
.file-ico.danger { background: rgba(255, 113, 133, 0.16); }
.file-meta { flex: 1; min-width: 0; }
.file-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-sub { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; }
.file-dl {
  flex: 0 0 auto;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--line);
  text-decoration: none;
}
.file-dl:hover { background: rgba(255, 255, 255, 0.14); text-decoration: none; }

.empty {
  margin: auto;
  padding: 30px;
  text-align: center;
  color: var(--muted-2);
  line-height: 2;
}
.empty .big { font-size: 42px; display: block; margin-bottom: 8px; opacity: 0.8; }

/* 输入区 */
.composer {
  border-top: 1px solid var(--line);
  padding: 10px 18px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  position: relative;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}
.tool-btn {
  border: 0;
  background: transparent;
  border-radius: 9px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.tool-btn:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-1px); }
.tool-hint { margin-left: auto; font-size: 11.5px; color: var(--muted-2); }

.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.composer-row textarea {
  flex: 1;
  min-height: 46px;
  max-height: 180px;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.5;
  background: rgba(9, 15, 29, 0.8);
}
.composer-row .primary { height: 46px; padding: 0 22px; border-radius: 14px; }

.upload-bar {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(109, 140, 255, 0.1);
  border: 1px solid rgba(109, 140, 255, 0.25);
}
.upload-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.upload-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.15s linear; }

.drop-hint {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #dbe5ff;
  background: rgba(9, 14, 28, 0.78);
  border: 2px dashed rgba(109, 140, 255, 0.7);
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   弹窗 / 提示
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 8, 18, 0.66);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 20px;
  background: linear-gradient(180deg, #16213c, #0e1729);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: rise 0.22s ease both;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal p { margin: 0 0 14px; }
.modal form { display: grid; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.suggests {
  margin-top: 16px;
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.suggest-item .avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.suggest-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-status { font-size: 11.5px; color: var(--muted-2); }
.suggest-status.online { color: var(--green); }

.toast-layer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 80;
  display: grid;
  gap: 10px;
  justify-items: end;
  pointer-events: none;
}
.toast {
  max-width: 340px;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(22, 32, 56, 0.97);
  border: 1px solid var(--line-strong);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: rgba(255, 113, 133, 0.55); }
.toast.success { border-color: rgba(53, 214, 160, 0.55); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(2, 5, 12, 0.92);
  display: grid;
  place-items: center;
  padding: 30px;
  cursor: zoom-out;
  animation: fade 0.18s ease both;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

/* --------------------------------------------------------------------------
   动画 / 响应式
   -------------------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 860px) {
  body { overflow: hidden; }
  .app {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    height: 100vh;
  }
  .sidebar, .chat {
    border-radius: 0;
    border: 0;
    height: 100vh;
  }
  .sidebar { display: flex; }
  .chat { display: none; }
  body.mobile-chat .sidebar { display: none; }
  body.mobile-chat .chat { display: grid; }
  .back-btn { display: grid; }
  .msg-main { max-width: 78%; }
  .messages { padding: 16px 14px 10px; }
  .composer { padding: 8px 12px 12px; }
  .tool-hint { display: none; }
  .file-card { min-width: 0; max-width: 100%; }
  .img-wrap { max-width: 240px; }
}

/* ==========================================================================
   好友列表 / 资料 / 表情 / 通知
   ========================================================================== */

.sidebar-tabs {
  display: flex;
  gap: 6px;
  padding: 4px 14px 6px;
}
.tab-btn {
  flex: 1;
  border: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 10px;
  padding: 7px 0;
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: rgba(109, 140, 255, 0.18);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(120, 150, 255, 0.3);
}
.tab-count {
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 10.5px;
  display: inline-grid;
  place-items: center;
  padding: 0 4px;
}
.tab-count:empty { display: none; }

#chats-panel, #friends-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.friend-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.friend-item:hover { background: rgba(255, 255, 255, 0.05); }
.friend-item .avatar { width: 36px; height: 36px; border-radius: 11px; font-size: 14px; }
.friend-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.friend-name {
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex: 0 0 auto;
}
.friend-sub { font-size: 11.5px; color: var(--muted-2); }
.friend-profile-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11.5px;
  cursor: pointer;
}
.friend-profile-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.friend-empty {
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 12.5px;
  line-height: 1.9;
}

/* 好友资料 */
.profile-modal { width: min(440px, 100%); }
.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.profile-head .avatar { width: 54px; height: 54px; border-radius: 17px; font-size: 22px; }
.profile-title { min-width: 0; }
.profile-title h2 {
  margin: 0 0 2px;
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-title .muted { font-size: 12px; }
.profile-head .icon-btn { margin-left: auto; align-self: flex-start; }
.profile-meta {
  display: grid;
  gap: 7px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.profile-meta .row2 { display: flex; justify-content: space-between; gap: 10px; }
.profile-meta b { color: var(--text); font-weight: 600; }
.profile-label { display: block; margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.profile-modal input { margin-bottom: 12px; }
.profile-bottom { margin-top: 8px; }

/* 表情面板 */
.emoji-panel {
  position: absolute;
  left: 18px;
  bottom: 104px;
  width: 336px;
  max-height: 264px;
  overflow-y: auto;
  background: rgba(18, 29, 51, 0.98);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: var(--shadow);
  z-index: 30;
  backdrop-filter: blur(10px);
}
.emoji-panel button {
  border: 0;
  background: transparent;
  font-size: 20px;
  padding: 4px 0;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.25;
}
.emoji-panel button:hover { background: rgba(255, 255, 255, 0.09); }

/* 纯表情消息放大 */
.bubble.emoji-only {
  background: transparent;
  border-color: transparent;
  padding: 2px 4px;
  font-size: 30px;
  line-height: 1.35;
  box-shadow: none;
}
.msg.own .bubble.emoji-only {
  background: transparent;
  box-shadow: none;
  border: 0;
  color: var(--text);
}

.chat-actions { display: flex; align-items: center; gap: 8px; }
#notify-btn { width: 30px; height: 30px; font-size: 14px; }
#notify-btn.off { opacity: 0.4; }

@media (max-width: 860px) {
  .emoji-panel { left: 12px; right: 12px; width: auto; bottom: 98px; }
}
/* 头像图片 */
.avatar img.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.me .avatar { cursor: pointer; }
.me .avatar::after {
  content: "换";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: rgba(5, 9, 18, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.me .avatar:hover::after { opacity: 1; }
/* 语音 */
.record-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(255, 113, 133, 0.1);
  border: 1px solid rgba(255, 113, 133, 0.32);
}
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: rec-pulse 1s ease-in-out infinite;
}
.rec-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 34px;
}
.rec-hint { flex: 1; font-size: 12px; color: var(--muted); }
.record-bar .mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); cursor: pointer; }
.record-bar .mini.primary { border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
#record-btn.recording { color: var(--danger); animation: rec-pulse 1s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: 0.35; } }

.voice-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  max-width: 320px;
  padding: 6px 8px;
}
.voice-play {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: filter 0.15s ease;
}
.voice-play:hover { filter: brightness(1.1); }
.voice-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.voice-bars { display: flex; align-items: center; gap: 2px; height: 22px; }
.voice-bars span {
  flex: 1;
  min-height: 3px;
  border-radius: 2px;
  background: rgba(170, 188, 230, 0.4);
  transition: background 0.15s ease;
}
.voice-bars span.played { background: #9db4ff; }
.msg.own .voice-bars span { background: rgba(255, 255, 255, 0.32); }
.msg.own .voice-bars span.played { background: #fff; }
.voice-dur {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
}
.msg.own .voice-dur { color: rgba(255, 255, 255, 0.82); }
/* 远程桌面 */
.sharing-bar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 30, 52, 0.96);
  border: 1px solid rgba(255, 113, 133, 0.45);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 12.5px;
}
.sharing-bar .mini {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.remote-view {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: #05080f;
  display: flex;
  flex-direction: column;
}
.remote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.96);
  border-bottom: 1px solid var(--line);
}
.remote-title { font-weight: 650; font-size: 14.5px; }
.remote-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.remote-body {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  position: relative;
  padding: 12px;
  background:
    radial-gradient(1000px 500px at 50% 0%, rgba(109, 140, 255, 0.08), transparent 60%),
    #05080f;
}
.remote-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  display: none;
}
.remote-body img.ready { display: block; }
.remote-empty {
  position: absolute;
  color: var(--muted);
  font-size: 13px;
}
/* ==========================================================================
   顶部图标 / 主题切换 / 浅色主题
   ========================================================================== */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  flex: 0 0 auto;
}
.brand-name { flex: 1; font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.brand .icon-btn { width: 30px; height: 30px; font-size: 15px; }

.theme-panel {
  position: absolute;
  top: 96px;
  right: 14px;
  z-index: 45;
  width: 176px;
  padding: 8px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  display: grid;
  gap: 3px;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}
.theme-option:hover { background: var(--hover, rgba(255, 255, 255, 0.06)); }
.theme-option.active { box-shadow: inset 0 0 0 1px var(--accent); }
.swatch {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  flex: 0 0 auto;
}
.swatch-dark { background: linear-gradient(135deg, #101a2f, #070b14); }
.swatch-white { background: linear-gradient(135deg, #ffffff, #e6edf8); }
.swatch-gold { background: linear-gradient(135deg, #f6d98a, #c9932e); }
.swatch-pink { background: linear-gradient(135deg, #ffd1e6, #e05a9b); }
.swatch-sky { background: linear-gradient(135deg, #d6ecff, #3d9be0); }

/* ---- 浅色主题变量 ---- */

html[data-theme="white"] {
  --bg: #eef3fb;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-2: #ffffff;
  --panel-3: #f2f6fd;
  --line: rgba(30, 55, 100, 0.12);
  --line-strong: rgba(30, 55, 100, 0.22);
  --text: #1b2433;
  --muted: #5c6b82;
  --muted-2: #8b98ab;
  --bubble: #eef3fb;
  --bubble-own: linear-gradient(135deg, #5f7dff, #8b63ff);
  --accent: #4f6cf0;
  --accent-2: #8a63f0;
  --shadow: 0 20px 50px rgba(30, 50, 90, 0.12);
  --hover: rgba(30, 60, 120, 0.06);
  --soft: rgba(25, 55, 110, 0.05);
  --input-bg: #ffffff;
  --glow1: rgba(109, 140, 255, 0.16);
  --glow2: rgba(154, 109, 255, 0.1);
  --glow3: rgba(53, 214, 160, 0.06);
  --toast-bg: rgba(255, 255, 255, 0.98);
  --modal-bg: linear-gradient(180deg, #ffffff, #f4f7fd);
  --day-bg: rgba(235, 241, 250, 0.9);
  --file-bg: rgba(245, 248, 255, 0.9);
  --emoji-bg: #ffffff;
  --voice-bar: rgba(70, 95, 140, 0.3);
}

html[data-theme="gold"] {
  --bg: #fdf6e6;
  --panel: rgba(255, 253, 246, 0.95);
  --panel-2: #fffdf7;
  --panel-3: #fbf1d8;
  --line: rgba(150, 110, 30, 0.16);
  --line-strong: rgba(150, 110, 30, 0.26);
  --text: #43351c;
  --muted: #7a6a4c;
  --muted-2: #a08a63;
  --bubble: #f7ecd2;
  --bubble-own: linear-gradient(135deg, #d9a441, #c07a2a);
  --accent: #c9932e;
  --accent-2: #e0b04d;
  --shadow: 0 20px 50px rgba(120, 90, 30, 0.12);
  --hover: rgba(160, 120, 40, 0.07);
  --soft: rgba(160, 120, 40, 0.06);
  --input-bg: #fffdf7;
  --glow1: rgba(240, 190, 80, 0.18);
  --glow2: rgba(220, 150, 60, 0.12);
  --glow3: rgba(200, 160, 60, 0.06);
  --toast-bg: rgba(255, 252, 243, 0.98);
  --modal-bg: linear-gradient(180deg, #fffdf7, #fbf1d8);
  --day-bg: rgba(250, 240, 215, 0.9);
  --file-bg: rgba(250, 243, 225, 0.9);
  --emoji-bg: #fffdf7;
  --voice-bar: rgba(150, 110, 50, 0.3);
}

html[data-theme="pink"] {
  --bg: #fdeef5;
  --panel: rgba(255, 248, 251, 0.95);
  --panel-2: #fff8fb;
  --panel-3: #fbe4ef;
  --line: rgba(180, 80, 130, 0.14);
  --line-strong: rgba(180, 80, 130, 0.24);
  --text: #45263a;
  --muted: #8a6478;
  --muted-2: #b08a9c;
  --bubble: #fbe4ef;
  --bubble-own: linear-gradient(135deg, #ef6aa8, #d94b8d);
  --accent: #e05a9b;
  --accent-2: #f07ab5;
  --shadow: 0 20px 50px rgba(160, 60, 110, 0.12);
  --hover: rgba(200, 80, 140, 0.07);
  --soft: rgba(200, 80, 140, 0.06);
  --input-bg: #fff8fb;
  --glow1: rgba(240, 120, 180, 0.16);
  --glow2: rgba(255, 150, 200, 0.1);
  --glow3: rgba(220, 100, 160, 0.06);
  --toast-bg: rgba(255, 248, 251, 0.98);
  --modal-bg: linear-gradient(180deg, #fff8fb, #fbe4ef);
  --day-bg: rgba(252, 235, 243, 0.9);
  --file-bg: rgba(253, 240, 246, 0.9);
  --emoji-bg: #fff8fb;
  --voice-bar: rgba(150, 80, 120, 0.28);
}

html[data-theme="sky"] {
  --bg: #eaf5ff;
  --panel: rgba(248, 252, 255, 0.95);
  --panel-2: #f8fcff;
  --panel-3: #e1f1ff;
  --line: rgba(40, 90, 150, 0.14);
  --line-strong: rgba(40, 90, 150, 0.24);
  --text: #17324d;
  --muted: #5e7a94;
  --muted-2: #8aa5bd;
  --bubble: #e1f1ff;
  --bubble-own: linear-gradient(135deg, #3d9be0, #2d7fc4);
  --accent: #3d9be0;
  --accent-2: #6bb8f0;
  --shadow: 0 20px 50px rgba(30, 80, 140, 0.12);
  --hover: rgba(50, 120, 190, 0.07);
  --soft: rgba(50, 120, 190, 0.06);
  --input-bg: #f8fcff;
  --glow1: rgba(80, 160, 240, 0.16);
  --glow2: rgba(120, 200, 255, 0.1);
  --glow3: rgba(80, 180, 220, 0.06);
  --toast-bg: rgba(248, 252, 255, 0.98);
  --modal-bg: linear-gradient(180deg, #f8fcff, #e1f1ff);
  --day-bg: rgba(230, 243, 255, 0.9);
  --file-bg: rgba(240, 248, 255, 0.9);
  --emoji-bg: #f8fcff;
  --voice-bar: rgba(60, 110, 160, 0.28);
}

/* ---- 浅色主题通用覆盖 ---- */

html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) body {
  background:
    radial-gradient(1100px 560px at 8% -12%, var(--glow1), transparent 62%),
    radial-gradient(900px 520px at 100% 0%, var(--glow2), transparent 58%),
    radial-gradient(700px 500px at 50% 120%, var(--glow3), transparent 60%),
    var(--bg);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) input,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) textarea {
  background: var(--input-bg);
  color: var(--text);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .composer-row textarea {
  background: var(--input-bg);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .conv-item:hover,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .friend-item:hover,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .icon-btn:hover,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .tool-btn:hover,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .file-dl:hover,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .emoji-panel button:hover,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .theme-option:hover {
  background: var(--hover);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .tab-btn,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .request-item,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .file-card,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .profile-meta,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .file-dl,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .themes-option {
  background: var(--soft);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .emoji-panel {
  background: var(--emoji-bg);
  border-color: var(--line-strong);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .modal {
  background: var(--modal-bg);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .login-card {
  background: var(--modal-bg);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .toast,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .sharing-bar {
  background: var(--toast-bg);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .day-sep {
  background: var(--day-bg);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .bubble a {
  color: var(--accent);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .msg.own .bubble a {
  color: #ffffff;
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .voice-bars span {
  background: var(--voice-bar);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) ::-webkit-scrollbar-thumb {
  background: rgba(60, 90, 140, 0.25);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .messages {
  background-image: radial-gradient(rgba(90, 115, 160, 0.08) 1px, transparent 1px);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .msg-image {
  background: rgba(0, 0, 0, 0.04);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .file-ico {
  background: var(--soft);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .login-hint,
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .hint {
  color: var(--muted-2);
}
/* 侧栏定位（主题弹层） */
.sidebar { position: relative; }
.theme-panel { top: 58px; }
/* 浅色主题下选中项的强调色跟随主题 */
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .conv-item.active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent);
}
html:is([data-theme="white"], [data-theme="gold"], [data-theme="pink"], [data-theme="sky"]) .tab-btn.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
/* ---- 消息操作 / 撤回 / 聊天记录 ---- */
.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 3px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-action {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
}
.msg-action:hover { color: var(--text); background: var(--hover); }
.msg-action.danger:hover { color: var(--danger); }
.msg.recalled { justify-content: center; padding: 4px 0; }
.recalled-line {
  color: var(--muted-2);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--soft);
}
.history-modal {
  width: min(620px, 94vw);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}
.history-modal input { margin-top: 10px; }
.history-list {
  margin-top: 10px;
  overflow: auto;
  display: grid;
  gap: 6px;
  min-height: 80px;
  max-height: 48vh;
  padding-right: 4px;
}
.history-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
}
.history-item .meta { color: var(--muted-2); font-size: 11px; margin-bottom: 3px; }
.history-item .content { white-space: pre-wrap; word-break: break-word; }
.history-empty { color: var(--muted); text-align: center; padding: 18px; }
@media (hover: none) {
  .msg-actions { opacity: 1; }
  .msg-action { padding: 4px 8px; font-size: 12px; }
}
@media (max-width: 860px) {
  #remote-btn { display: none !important; }
}
/* ---- 版本更新 ---- */
.update-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  font-size: 13px;
}
.update-banner span { flex: 1; }
.update-banner .primary { padding: 6px 12px; font-size: 12px; }
.update-notes {
  margin: 10px 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}