:root {
  --paper: #f4f1ea;
  --paper-deep: #ece7db;
  --surface: #fffdf8;
  --surface-2: #faf7ef;
  --surface-3: #f2eee3;
  --ink: #1d2721;
  --ink-2: #48564e;
  --muted: #8a948c;
  --line: #e7e1d3;
  --line-strong: #d9d2c2;
  --jade: #1f7a5c;
  --jade-deep: #14563f;
  --jade-soft: #e4f2ea;
  --amber: #b9761c;
  --rose: #bf4d5b;
  --sky: #3a6f9c;
  --violet: #6f5aa8;
  --slate: #5b6b77;
  --shadow-sm: 0 1px 2px rgba(29, 39, 33, 0.05);
  --shadow-md: 0 18px 40px -22px rgba(29, 39, 33, 0.35);
  --shadow-lg: 0 30px 70px -30px rgba(29, 39, 33, 0.4);
  --radius: 18px;
  --sidebar-w: 356px;
  --font: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  position: fixed;
  inset: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 100% 0%, #fbf8f1 0%, transparent 60%),
    radial-gradient(900px 700px at 0% 100%, #eee9dc 0%, transparent 55%),
    var(--paper);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: #cfe9dd; color: var(--jade-deep); }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

svg { display: block; }

[hidden] { display: none !important; }

/* ------------------------------- 启动 -------------------------------- */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 18px;
  background: var(--paper);
  z-index: 60;
  transition: opacity 0.35s ease;
}

.boot.done { opacity: 0; pointer-events: none; }

.boot-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(145deg, #2b8f6c, var(--jade-deep));
  color: #fffdf8;
  font-size: 26px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: breathe 1.8s ease-in-out infinite;
}

.boot-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jade);
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.02); }
}

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

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

.auth {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.auth-visual {
  position: relative;
  overflow: hidden;
  color: #f2f7f3;
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(255, 255, 255, 0.1), transparent 55%),
    radial-gradient(700px 700px at 95% 95%, rgba(0, 0, 0, 0.28), transparent 60%),
    linear-gradient(150deg, #1b6e53 0%, #14563f 55%, #0f4231 100%);
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(25deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 64px);
  mask-image: radial-gradient(80% 80% at 30% 30%, #000 20%, transparent 80%);
}

.auth-visual::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -120px;
  bottom: -140px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 0 0 60px rgba(255, 255, 255, 0.03), 0 0 0 130px rgba(255, 255, 255, 0.02);
}

.auth-visual-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(36px, 6vw, 88px) clamp(32px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-mark.big {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #f4fbf6;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.6);
}

.brand-mark.big svg { width: 46px; height: 46px; }

.auth-visual h1 {
  margin: 26px 0 4px;
  font-size: clamp(40px, 4.4vw, 58px);
  letter-spacing: 0.06em;
  font-weight: 600;
}

.auth-visual .tagline {
  margin: 0 0 44px;
  font-size: 15px;
  letter-spacing: 0.18em;
  color: rgba(240, 248, 242, 0.72);
}

.auth-points {
  list-style: none;
  padding: 0;
  margin: 0 0 48px;
  display: grid;
  gap: 22px;
  max-width: 420px;
}

.auth-points li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: start;
}

.auth-points duration { color: inherit; }

.auth-points li > span {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(240, 248, 242, 0.5);
  padding-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.auth-points strong {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 3px;
}

.auth-points p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: rgba(240, 248, 242, 0.62);
}

.auth-foot {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.12em;
  color: rgba(240, 248, 242, 0.42);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px clamp(24px, 5vw, 72px);
  min-width: 0;
  max-width: 100%;
}

.auth-card {
  width: min(400px, 100%);
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 38px 34px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-card-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: 0.01em;
}

.auth-card-head p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  gap: 4px;
  background: var(--surface-3);
  border-radius: 12px;
  margin-bottom: 24px;
}

.seg {
  border: 0;
  background: transparent;
  padding: 8px 0;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--ink-2);
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.seg.is-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.field { display: block; margin-bottom: 16px; }

.field > span {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field input::placeholder { color: #a9b1a9; }

.field input:focus {
  border-color: var(--jade);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(31, 122, 92, 0.12);
}

.code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.code-row input { flex: 1; min-width: 0; }

.code-row .btn {
  flex: none;
  white-space: nowrap;
  padding: 0 12px;
}

.link-btn {
  display: inline-block;
  border: 0;
  background: transparent;
  color: var(--jade);
  font-size: 12px;
  padding: 0 0 12px;
  cursor: pointer;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
}

.remember-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--jade);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 18px;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  font-size: 13.5px;
  transition: transform 0.15s ease, background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.btn:hover { border-color: #c8c0ae; background: #fffefb; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(160deg, #268a67, var(--jade-deep));
  color: #f7fbf8;
  border-color: transparent;
  box-shadow: 0 14px 26px -14px rgba(20, 86, 63, 0.65);
}

.btn.primary:hover { background: linear-gradient(160deg, #2c9570, #0f4a36); }

.btn.block { width: 100%; padding: 12px; font-size: 14px; margin-top: 6px; }
.btn.primary svg { width: 18px; height: 18px; }

.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink-2);
}

.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.small { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }

.hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.form-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fbeceb;
  color: #a53946;
  font-size: 12.5px;
}

.auth-legal {
  margin: 0;
  font-size: 11.5px;
  color: #9aa39b;
  letter-spacing: 0.03em;
}

/* -------------------------------- 应用 ------------------------------- */

.app {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 2;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 8px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
}

.side-head-actions { display: flex; align-items: center; gap: 2px; }

.brand { display: flex; align-items: center; gap: 10px; }

.brand-glyph {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #f6fbf7;
  font-size: 14px;
  background: linear-gradient(150deg, #2b8f6c, var(--jade-deep));
  box-shadow: 0 8px 16px -10px rgba(20, 86, 63, 0.8);
}

.brand-glyph svg { width: 20px; height: 20px; }

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.tiny { width: 24px; height: 24px; font-size: 17px; color: var(--muted); }

.me-card {
  margin: 12px 16px 4px;
  padding: 12px;
  border-radius: 16px;
  background:
    radial-gradient(120% 140% at 0% 0%, #ffffff 0%, transparent 55%),
    linear-gradient(135deg, #eef6f0, #f7f3e9);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 11px;
}

.me-meta { min-width: 0; flex: 1; }
.me-meta strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-meta span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  background: #fff9e9;
  color: #8a6716;
  border: 1px solid #f0e3bd;
  white-space: nowrap;
}

.conn i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.conn b { font-weight: 500; }

.conn[data-state="online"] { background: #e9f5ee; color: #1c6d51; border-color: #cfe7db; }
.conn[data-state="online"] i { animation: pulse 2.4s ease-in-out infinite; }
.conn[data-state="offline"] { background: #fbeceb; color: #a53946; border-color: #f2d5d3; }
.conn[data-state="connecting"] i { animation: blink 1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31, 122, 92, 0.35); }
  50% { box-shadow: 0 0 0 4px rgba(31, 122, 92, 0); }
}

.search {
  margin: 12px 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.search:focus-within {
  border-color: #b9d8c9;
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(31, 122, 92, 0.08);
}

.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
}

.search input::placeholder { color: #a4ada5; }

.side-tabs {
  display: flex;
  gap: 4px;
  order: 50;
  margin-top: auto;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 -18px 34px -30px rgba(29, 39, 33, 0.45);
}

.side-tabs button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.15;
  padding: 7px 4px;
  border-radius: 12px;
  transition: color 0.16s ease, background 0.16s ease;
}

.tab-icon { display: block; width: 22px; height: 22px; flex: none; }

.side-tabs button:hover { color: var(--ink); background: var(--surface-2); }

.side-tabs button.is-active {
  color: var(--jade-deep);
  background: #edf7f1;
  font-weight: 600;
}

.side-tabs button.is-active::after { display: none; }

.tab-badge {
  display: inline-grid;
  place-items: center;
  position: absolute;
  top: 4px;
  right: calc(50% - 26px);
  min-width: 16px;
  height: 15px;
  margin-left: 0;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--jade);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
}

.side-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 10px 16px;
}

.side-body::-webkit-scrollbar { width: 8px; }
.side-body::-webkit-scrollbar-thumb { background: #e0dacb; border-radius: 8px; border: 2px solid var(--surface); }

.pane { display: grid; gap: 2px; align-content: start; }

.side-foot {
  order: 40;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px 14px;
  font-size: 11px;
  color: #9aa39b;
  border-top: 1px solid var(--line);
}

.dot-jade {
  width: 6px; height: 6px; border-radius: 50%;
  background: #59b089;
}

.conv-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 10px 10px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  text-align: left;
  transition: background 0.16s ease;
}

.conv-item:hover { background: var(--surface-2); }

.conv-item.is-active { background: var(--jade-soft); }
.conv-item.is-active .conv-name { color: var(--jade-deep); }

.conv-main { min-width: 0; }

.conv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conv-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 10.5px;
  color: var(--muted);
  flex: none;
}

.conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.conv-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.conv-preview.mine::before { content: "你："; color: #a7b0a8; }
.conv-item.has-unread .conv-preview { color: var(--ink-2); }

.badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--jade);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
}

.badge.soft { background: #dfeae3; color: var(--jade-deep); }

/* 头像 */

.avatar {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #fffdf8;
  background: linear-gradient(150deg, #2b8f6c, #14563f);
  user-select: none;
  letter-spacing: 0;
  overflow: hidden;
}

.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 12px; }
.avatar.md { width: 40px; height: 40px; border-radius: 13px; font-size: 16px; }
.avatar.lg { width: 48px; height: 48px; border-radius: 15px; font-size: 19px; }
.avatar.xl { width: 64px; height: 64px; border-radius: 20px; font-size: 26px; }

.av-jade { background: linear-gradient(150deg, #2b8f6c, #14563f); }
.av-sky { background: linear-gradient(150deg, #5591c2, #2c5d88); }
.av-amber { background: linear-gradient(150deg, #d59b48, #a86a16); }
.av-rose { background: linear-gradient(150deg, #d4757f, #a83f4c); }
.av-violet { background: linear-gradient(150deg, #8d79c9, #5f4b98); }
.av-slate { background: linear-gradient(150deg, #7c8c96, #4d5d68); }

.avatar .online-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #45a97d;
  border: 2px solid var(--surface);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

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

.chat {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  overflow: hidden;
  background:
    radial-gradient(1000px 600px at 100% 0%, rgba(255, 253, 248, 0.9), transparent 60%),
    linear-gradient(180deg, #f5f2ea, #f1ece1);
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px;
  text-align: center;
}

.empty-art { width: 220px; margin-bottom: 8px; opacity: 0.95; }
.empty-art svg { width: 100%; height: auto; }

.chat-empty h2 { margin: 0; font-size: 19px; font-weight: 600; }
.chat-empty p { margin: 0; color: var(--muted); font-size: 13px; max-width: 380px; line-height: 1.7; }

.empty-tips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 20px; }
.empty-tips span {
  font-size: 11px;
  color: #8b958c;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 253, 248, 0.6);
}

.chat-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 24px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: rgba(255, 253, 248, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.chat-head .back { display: none; }

.chat-title { min-width: 0; flex: 1; }

.chat-title strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-title span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-title span.is-online { color: #2f8a63; }
.chat-title span.is-typing { color: var(--jade); }

.chat-secure {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #9aa39b;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.chat-secure svg { width: 18px; height: 18px; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 28px 8px;
  scroll-behavior: smooth;
  position: relative;
}

.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb { background: #ddd6c7; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

.message-list {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 18px;
}

.load-more { display: flex; justify-content: center; padding: 2px 0 14px; }

.day-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: #9ba49c;
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.day-sep::before, .day-sep::after {
  content: "";
  height: 1px;
  width: 42px;
  background: linear-gradient(90deg, transparent, #d9d2c3);
}
.day-sep::after { background: linear-gradient(90deg, #d9d2c3, transparent); }

.msg-row {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  margin-top: 10px;
  animation: rise 0.22s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.msg-row.cont { margin-top: 3px; }
.msg-row .avatar { margin-bottom: 18px; }
.msg-row.cont .avatar { visibility: hidden; }

.msg-stack { max-width: min(72%, 560px); display: flex; flex-direction: column; align-items: flex-start; }

.bubble {
  padding: 9px 13px;
  border-radius: 16px 16px 16px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 13.8px;
  line-height: 1.62;
  color: var(--ink);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 3px 0;
  font-size: 10.5px;
  color: #9ba49c;
  min-height: 14px;
}

.msg-row.mine { flex-direction: row-reverse; }
.msg-row.mine .msg-stack { align-items: flex-end; }

.msg-row.mine .bubble {
  background: linear-gradient(150deg, #25825f, #176049);
  border-color: transparent;
  color: #f7fbf8;
  border-radius: 16px 16px 6px 16px;
  box-shadow: 0 10px 20px -14px rgba(20, 86, 63, 0.7);
}

.msg-row.mine .msg-meta { justify-content: flex-end; }

.msg-sender {
  margin: 0 4px 3px;
  font-size: 10.5px;
  color: var(--muted);
}

.msg-row.system {
  justify-content: center;
  margin: 12px 0;
}

.msg-row.system .msg-stack {
  max-width: 90%;
  align-items: center;
}

.msg-system-text {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.7);
  border: 1px solid var(--line);
  color: #8b958c;
  font-size: 11px;
  text-align: center;
}

.msg-row.recalled {
  justify-content: center;
  margin: 10px 0;
}

.msg-row.recalled .msg-stack {
  max-width: 90%;
  align-items: center;
}

.bubble.media {
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.msg-row.mine .bubble.media {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.bubble.media-audio {
  padding: 8px 10px;
}

.msg-image {
  display: block;
  max-width: min(280px, 66vw);
  max-height: 340px;
  border-radius: 13px;
  cursor: zoom-in;
  object-fit: cover;
}

.msg-video {
  display: block;
  width: min(320px, 68vw);
  max-height: 360px;
  border-radius: 13px;
  background: #000;
}

.msg-audio {
  display: block;
  width: 250px;
  max-width: 64vw;
  height: 36px;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  max-width: min(360px, 68vw);
  padding: 10px 12px;
  text-decoration: none;
  color: var(--ink);
}

.msg-file-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 10px;
  background: var(--jade-soft);
  color: var(--jade-deep);
  font-size: 17px;
}

.msg-file-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-file-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-file-meta {
  font-size: 10.5px;
  color: var(--muted);
}

.msg-media-meta {
  display: block;
  margin: 4px 6px 2px;
  font-size: 10.5px;
  color: var(--muted);
}

.receipt { font-size: 10.5px; color: #9ba49c; }
.receipt.read { color: #4b9a76; }
.receipt.failed { color: var(--rose); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.receipt.sending { color: #a9a293; }

.msg-meta .receipt[hidden] { display: none; }

.jump-latest {
  position: sticky;
  bottom: 6px;
  left: 100%;
  transform: translateX(-8px);
  border: 1px solid #cfe4d8;
  background: #f2faf5;
  color: var(--jade-deep);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* 编辑器 */

.composer {
  padding: 6px clamp(16px, 3vw, 28px) 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, #f1ece1 34%);
}

.composer-box {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 34px -26px rgba(29, 39, 33, 0.5);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer-box:focus-within {
  border-color: #b4d5c5;
  box-shadow: 0 0 0 4px rgba(31, 122, 92, 0.07), 0 16px 34px -26px rgba(29, 39, 33, 0.5);
}

.composer textarea {
  flex: 1;
  min-height: 30px;
  max-height: 150px;
  padding: 4px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.6;
  overflow-y: auto;
}

.composer textarea::placeholder { color: #a7b0a7; }

.composer-tools { display: flex; align-items: center; gap: 4px; }

.voice-cancel-row {
  display: flex;
  justify-content: center;
  padding-top: 6px;
}

.attach-pop {
  position: absolute;
  left: 6px;
  bottom: calc(100% + 8px);
  z-index: 30;
  display: flex;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.attach-pop button {
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  transition: background 0.16s ease, color 0.16s ease;
}

.attach-pop button:hover {
  background: var(--surface-2);
  color: var(--jade-deep);
}

.attach-pop svg {
  width: 23px;
  height: 23px;
}

.attach-pop[hidden] { display: none; }

.emoji-btn {
  font-size: 19px;
  width: 34px;
  height: 34px;
  color: #8f9a91;
}

.attach-btn svg, .voice-btn svg { width: 18px; height: 18px; }

.voice-btn.recording {
  color: #b03f4c;
  background: #fbeceb;
  border-color: #f1d2d0;
  animation: pulse 1.2s ease-in-out infinite;
}

.composer-hint.recording { color: #b03f4c; }
.composer-hint.uploading { color: var(--jade); }

.counter { font-size: 10.5px; color: #b3aa99; min-width: 0; }
.counter.warn { color: var(--amber); }

.send-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: #f7fbf8;
  background: linear-gradient(150deg, #2b9370, #16614a);
  box-shadow: 0 10px 18px -12px rgba(20, 86, 63, 0.8);
  transition: transform 0.16s ease, opacity 0.16s ease, filter 0.16s ease;
}

.send-btn svg { width: 20px; height: 20px; }
.send-btn:hover { filter: brightness(1.06); }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.35; cursor: default; box-shadow: none; }

.composer-hint {
  max-width: 780px;
  margin: 7px auto 0;
  font-size: 10.5px;
  color: #a8a193;
  text-align: center;
  letter-spacing: 0.02em;
}

.emoji-pop {
  position: absolute;
  right: 8px;
  bottom: 58px;
  width: 268px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 6;
}

.emoji-pop button {
  border: 0;
  background: transparent;
  font-size: 19px;
  line-height: 1;
  padding: 6px 0;
  border-radius: 8px;
}

.emoji-pop button:hover { background: var(--jade-soft); }

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.avatar-upload-row .hint { margin: 0; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 18, 14, 0.88);
  backdrop-filter: blur(4px);
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

/* ------------------------------ 设置弹窗 ------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 33, 27, 0.42);
  backdrop-filter: blur(6px);
  animation: fade 0.2s ease;
}

@keyframes fade { from { opacity: 0; } }

.modal-card {
  width: min(620px, 100%);
  max-height: min(760px, 90dvh);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: lift 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes lift {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 { margin: 0; font-size: 18px; }

.modal-body { overflow-y: auto; padding: 8px 24px 24px; }

.settings-block { padding: 20px 0; border-bottom: 1px solid var(--line); }
.settings-block:last-child { border-bottom: 0; }

.settings-block h3 {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.profile-row { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.profile-fields { flex: 1; min-width: 0; }
.profile-fields .field:last-child { margin-bottom: 0; }
.profile-row .avatar { margin-top: 4px; }

.swatch-title { font-size: 11.5px; color: var(--muted); margin: 12px 0 8px; }

.emoji-row, .color-row { display: flex; flex-wrap: wrap; gap: 6px; }

.emoji-row button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 17px;
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.emoji-row button.is-active { border-color: var(--jade); background: var(--jade-soft); }
.emoji-row button:hover { transform: translateY(-1px); }

.color-row button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 2px var(--surface);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-row button.is-active { border-color: var(--ink); transform: scale(1.08); }

.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.settings-actions .hint { margin: 0; color: #3c8a68; }

.session-list { display: grid; gap: 8px; }
.session-summary { margin: 0 0 4px; }

.manage-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--ink);
  text-align: left;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.manage-row:hover {
  background: #fff;
  border-color: #cfe7db;
}

.manage-main { flex: 1; min-width: 0; }
.manage-main strong { display: block; font-size: 13px; font-weight: 600; }
.manage-main span { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.manage-chevron { flex: none; color: var(--muted); font-size: 22px; line-height: 1; }

.version-current-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.version-current-row strong {
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.version-current-row .hint { margin: 0; }

.network-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}

.network-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}

.session-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.session-row .session-main { flex: 1; min-width: 0; }
.session-row strong { display: block; font-size: 13px; font-weight: 600; }
.session-row span { font-size: 11px; color: var(--muted); }

.pill-current {
  font-size: 10px;
  color: var(--jade-deep);
  background: var(--jade-soft);
  border: 1px solid #cfe7db;
  padding: 2px 7px;
  border-radius: 999px;
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.notice-switches { display: grid; gap: 12px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: #ddd6c7;
  position: relative;
  transition: background 0.18s ease;
  flex: none;
}

.switch-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track { background: var(--jade); }
.switch input:checked + .switch-track i { transform: translateX(17px); }
.switch-label { font-size: 13px; }

.danger-block .btn.ghost { color: #a53946; border-color: #edcfcd; }
.danger-block .btn.ghost:hover { background: #fdf0ef; }

/* -------------------------------- 提示 ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(8px);
  z-index: 70;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(26, 36, 30, 0.92);
  color: #f4f7f5;
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: min(420px, 88vw);
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-clickable { pointer-events: auto; cursor: pointer; }
.toast.error { background: rgba(150, 48, 58, 0.94); }

/* 群聊与消息菜单 */

.member-picker {
  display: grid;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.member-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
}

.member-option:hover { background: var(--surface); }
.member-option input { accent-color: var(--jade); width: 16px; height: 16px; }

.member-list { display: grid; gap: 6px; }

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}

.member-row .person-main { flex: 1; min-width: 0; }

.role-pill {
  font-size: 10px;
  color: var(--jade-deep);
  background: var(--jade-soft);
  border: 1px solid #cfe7db;
  padding: 2px 7px;
  border-radius: 999px;
}

.message-menu {
  position: fixed;
  z-index: 85;
  min-width: 120px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
}

.message-menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--ink);
}

.message-menu button:hover { background: var(--surface-2); }
.message-menu button[data-action="delete"] { color: #a53946; }

.msg-image, .msg-video { cursor: pointer; }

/* ------------------------------- 空状态 ------------------------------- */

.pane-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.pane-empty strong {
  display: block;
  color: var(--ink-2);
  font-size: 13px;
  margin-bottom: 4px;
}

.pane-empty .btn { margin-top: 12px; }

.list-label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: #a2aba2;
  padding: 12px 10px 6px;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 12px;
  transition: background 0.16s ease;
}

.person-row:hover { background: var(--surface-2); }

.person-main { flex: 1; min-width: 0; }
.person-main strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-main span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-actions { display: flex; gap: 6px; flex: none; }

.person-row .btn.small { padding: 5px 9px; }

.request-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  margin-bottom: 6px;
}

.request-top { display: flex; gap: 10px; align-items: center; }
.request-text { font-size: 12px; color: var(--ink-2); margin: 8px 0 10px; padding-left: 2px; }
.request-text.empty { color: var(--muted); font-style: italic; }
.request-actions { display: flex; gap: 8px; }

.search-hint { padding: 10px; font-size: 11.5px; color: var(--muted); }

.msg-link {
  color: #17694f;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(23, 105, 79, 0.35);
  word-break: break-all;
}

.msg-row.mine .msg-link { color: #d9f5e8; text-decoration-color: rgba(217, 245, 232, 0.5); }

.thread-skeleton { display: flex; flex-direction: column; gap: 14px; padding: 24px 0; }
.skel-row { display: flex; }
.skel-row.right { justify-content: flex-end; }
.skel-bubble {
  display: block;
  width: 220px;
  height: 38px;
  border-radius: 14px;
  background: linear-gradient(90deg, #ece7da 25%, #f7f3e8 37%, #ece7da 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
}
.skel-row:nth-child(2) .skel-bubble { width: 300px; }
.skel-row:nth-child(3) .skel-bubble { width: 170px; height: 56px; }
.skel-row:nth-child(4) .skel-bubble { width: 260px; height: 56px; }
.skel-row:nth-child(5) .skel-bubble { width: 140px; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 980px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-visual { display: none; }
  .auth-panel { background: var(--paper); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; }
  .chat { display: none; }
  body.chat-open .sidebar { display: none; }
  body.chat-open .chat { display: flex; }
  .chat-head .back { display: grid; }
  .chat-head {
    padding: 12px 12px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .messages { padding: 14px 14px 6px; }
  .msg-stack { max-width: 82%; }
  .composer {
    padding: 4px 10px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .composer-hint { display: none; }
  .chat-empty { display: none; }
  .side-body { padding-bottom: 28px; }
  .side-tabs {
    order: 50;
    margin-top: auto;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 -18px 34px -30px rgba(29, 39, 33, 0.45);
    backdrop-filter: blur(10px);
  }
  .side-tabs button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 4px;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.15;
  }
  .side-tabs button.is-active {
    color: var(--jade-deep);
    background: #edf7f1;
  }
  .side-tabs button.is-active::after { display: none; }
  .side-tabs .tab-icon { display: block; }
  .side-tabs .tab-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 26px);
    margin-left: 0;
    min-width: 15px;
    height: 15px;
    font-size: 9px;
  }
  .side-foot { display: none; }
}

@media (max-width: 560px) {
  .modal { padding: 0; place-items: stretch; }
  .modal-card { width: 100%; max-height: 100dvh; border-radius: 0; border: 0; }
  .auth-card { padding: 28px 18px 24px; width: 100%; border-radius: 20px; }
  .auth-panel { padding: 22px 14px; }
  .auth-tabs { gap: 4px; }
  .code-row { gap: 8px; }
  .code-row button { padding: 0 14px; }
  .profile-row { flex-direction: column; align-items: center; text-align: center; }
  .profile-fields { width: 100%; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
