:root {
  --ink: #172033;
  --muted: #7c879c;
  --line: #e7ecf5;
  --blue: #4f7cff;
  --blue-dark: #3866ef;
  --blue-soft: #e9f0ff;
  --bg: #eef3fb;
  --panel: #ffffff;
  --chat-bg: #f6f8fd;
  --bubble: #ffffff;
  --shadow: 0 18px 60px rgba(40, 68, 130, 0.14);
  --radius: 22px;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.85), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(79,124,255,.15), transparent 32%),
    linear-gradient(135deg, #edf4ff 0%, #f7f9ff 48%, #e9f1ff 100%);
}
.login-orb { position: absolute; border-radius: 999px; filter: blur(2px); opacity: .75; pointer-events: none; }
.orb-a { width: 340px; height: 340px; left: -90px; bottom: -110px; background: radial-gradient(circle at 35% 30%, #d8e6ff, #b9d0ff 55%, rgba(185,208,255,0) 72%); }
.orb-b { width: 260px; height: 260px; right: -60px; top: -70px; background: radial-gradient(circle at 40% 40%, #dbe8ff, #c3d7ff 55%, rgba(195,215,255,0) 72%); }
.login-card {
  position: relative;
  z-index: 2;
  width: min(390px, 100%);
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: var(--shadow);
  border-radius: 30px;
  padding: 34px 30px 26px;
  backdrop-filter: blur(18px);
  animation: rise .55s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.brand-mark { width: 64px; height: 64px; border-radius: 20px; background: linear-gradient(145deg, #5f8bff, #3d67e8); position: relative; box-shadow: 0 12px 24px rgba(79,124,255,.3); margin-bottom: 18px; }
.fish-shape { position: absolute; width: 30px; height: 18px; border-radius: 50% 60% 55% 45%; background: #fff; left: 16px; top: 22px; transform: rotate(-8deg); }
.fish-shape::after { content: ""; position: absolute; right: -7px; top: 3px; width: 12px; height: 12px; background: #fff; clip-path: polygon(0 50%, 100% 0, 100% 100%); }
.fish-shape::before { content: ""; position: absolute; left: 8px; top: 6px; width: 3px; height: 3px; border-radius: 50%; background: #3d67e8; }
.bubble { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.8); }
.b1 { width: 7px; height: 7px; right: 11px; top: 13px; }
.b2 { width: 5px; height: 5px; right: 8px; top: 24px; opacity: .7; }
.login-card h1 { margin: 0; font-size: 30px; letter-spacing: .08em; }
.login-sub { margin: 8px 0 24px; color: var(--muted); font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: #64708a; margin: 0 0 7px 4px; letter-spacing: .04em; }
.field input {
  width: 100%; border: 1px solid var(--line); background: #f8faff;
  border-radius: 14px; padding: 13px 14px; outline: none; color: var(--ink);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus { border-color: #a9c1ff; background: #fff; box-shadow: 0 0 0 4px rgba(79,124,255,.1); }
.primary-btn {
  width: 100%; border: 0; border-radius: 14px; padding: 14px 18px;
  background: linear-gradient(135deg, #5c86ff, #3f6aef);
  color: #fff; font-weight: 700; letter-spacing: .04em;
  box-shadow: 0 10px 22px rgba(79,124,255,.3);
  transition: transform .15s, box-shadow .15s;
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(79,124,255,.36); }
.primary-btn:active { transform: translateY(0); }
.login-error { margin: 10px 2px 0; font-size: 12px; color: #c65363; }
.login-hint { margin: 18px 0 0; text-align: center; font-size: 11px; color: #98a3b6; }

/* ---------- app shell ---------- */
.app-view { height: 100%; display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.sidebar {
  background: rgba(255,255,255,.92);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
  position: relative; z-index: 3;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 14px; }
.sidebar-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.brand-small { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .08em; font-size: 17px; }
.brand-dot { width: 12px; height: 12px; border-radius: 4px 7px 7px 4px; background: linear-gradient(135deg, #6c95ff, #3f6aef); box-shadow: 0 0 0 4px #edf2ff; position: relative; }
.brand-dot::after { content: ""; position: absolute; right: -5px; top: 3px; border-left: 5px solid #4f7cff; border-top: 3px solid transparent; border-bottom: 3px solid transparent; }
.icon-btn {
  width: 38px; height: 38px; border: 0; border-radius: 12px; background: transparent; color: #6c7891;
  display: grid; place-items: center; transition: background .18s, color .18s;
}
.icon-btn:hover { background: #f1f5fd; color: var(--blue); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.search-wrap {
  margin: 0 15px 13px; padding: 0 12px; height: 42px; border-radius: 13px;
  background: #f4f7fc; border: 1px solid transparent; display: flex; align-items: center; gap: 8px;
  transition: border-color .2s, background .2s;
}
.search-wrap:focus-within { background: #fff; border-color: #cfdcff; }
.search-wrap svg { width: 17px; height: 17px; fill: none; stroke: #9aa7bc; stroke-width: 1.9; stroke-linecap: round; }
.search-wrap input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13px; color: var(--ink); }
.search-wrap input::placeholder { color: #a4afc1; }
.list-label { padding: 4px 22px 8px; font-size: 11px; font-weight: 700; letter-spacing: .16em; color: #a1acbd; }

.conversation-list { padding: 0 10px 10px; overflow: auto; flex: 1; }
.conv-item {
  width: 100%; border: 0; background: transparent; text-align: left;
  display: flex; gap: 11px; align-items: center; padding: 12px 11px;
  border-radius: 17px; transition: background .18s, transform .18s;
  position: relative;
}
.conv-item:hover { background: #f5f8ff; }
.conv-item.active { background: linear-gradient(135deg, #edf2ff, #f2f6ff); }
.conv-item.active::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 4px; background: var(--blue); }
.avatar {
  width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; overflow: hidden;
  display: inline-grid; place-items: center; background: #dfe8ff; color: #466be0;
  font-weight: 800; font-size: 15px; position: relative; user-select: none;
}
.avatar-img { object-fit: cover; background: #e9eef9; }
.conv-copy { min-width: 0; flex: 1; }
.conv-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 14px; font-weight: 700; color: #263248; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: #a3aec0; white-space: nowrap; }
.conv-preview { margin-top: 5px; font-size: 12px; color: #8a96aa; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px;
  background: var(--blue); color: #fff; font-size: 10px; font-weight: 800;
  display: grid; place-items: center; margin-left: 4px; box-shadow: 0 4px 10px rgba(79,124,255,.3);
}
.sidebar-foot { padding: 12px 12px 14px; border-top: 1px solid #f0f3f9; }
.me-row { width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 15px; text-align: left; }
.me-row:hover { background: #f5f8ff; }
.me-row .avatar { width: 40px; height: 40px; flex-basis: 40px; font-size: 14px; }
.me-copy { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.me-copy strong { font-size: 13px; }
.me-copy small { color: #9aa6b9; font-size: 11px; }
.chev { color: #aab4c5; font-size: 20px; }

/* ---------- chat ---------- */
.chat-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--chat-bg); position: relative; }
.chat-head {
  height: 72px; flex: 0 0 72px; padding: 0 18px; display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.88); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px); position: relative; z-index: 2;
}
.back-btn { display: none; }
.chat-person { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.chat-person .avatar { width: 42px; height: 42px; flex-basis: 42px; }
.chat-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chat-meta strong { font-size: 15px; letter-spacing: .01em; }
.chat-meta small { color: #93a0b4; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta small.online { color: #38a878; }
.chat-meta small.online::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #3cbd86; margin-right: 5px; vertical-align: 1px; }
.head-actions { display: flex; gap: 2px; }
.messages {
  flex: 1; min-height: 0; overflow: auto; padding: 22px clamp(16px, 5vw, 54px) 32px;
  display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: auto;
}
.day-divider { align-self: center; margin: 4px 0 15px; font-size: 10px; color: #a3afc1; background: rgba(255,255,255,.72); border: 1px solid #eef2f9; padding: 4px 11px; border-radius: 999px; }
.msg-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 13px; max-width: 100%; }

.msg-row.left { align-self: flex-start; }
.msg-row.right { align-self: stretch; flex-direction: row; justify-content: flex-end; width: 100%; max-width: 100%; margin-left: 0; }
.msg-row .avatar { width: 34px; height: 34px; flex-basis: 34px; font-size: 11px; margin-bottom: 2px; }
.msg-body { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.msg-row.right .msg-body { align-items: flex-end; }
.msg-name { font-size: 11px; font-weight: 600; color: #6f7d94; margin: 0 0 2px 4px; }
.msg-row.right .msg-name { margin: 0 4px 2px 0; color: #71809a; text-align: right; }
.bubble {
  width: max-content;
  max-width: min(520px, 68vw);
  position: static;
  padding: 10px 14px; border-radius: 17px 17px 17px 5px;
  background: var(--bubble); border: 1px solid #edf1f8;
  box-shadow: 0 5px 16px rgba(45,75,135,.045);
  font-size: 14px; line-height: 1.55; color: #2a3548;
  word-break: break-word; white-space: pre-wrap;
}
.msg-row.right .bubble { background: linear-gradient(135deg, #5a84ff, #426fee); color: #fff; border-color: transparent; border-radius: 17px 17px 5px 17px; box-shadow: 0 7px 18px rgba(79,124,255,.24); }
.msg-time { font-size: 10px; color: #adb7c7; padding: 0 4px; }
.msg-row.right .msg-time { text-align: right; }
.bubble.sticker { background: transparent; border: 0; box-shadow: none; padding: 2px 0; font-size: 40px; line-height: 1; }
.msg-image { width: min(240px, 48vw); border-radius: 15px; display: block; border: 1px solid rgba(255,255,255,.4); box-shadow: 0 8px 20px rgba(33,58,110,.12); }
.typing { display: flex; gap: 4px; align-items: center; height: 20px; padding: 0 5px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #a9b6cb; animation: blink 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 70%, 100% { opacity: .3; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
.empty-state { margin: auto; text-align: center; color: #97a3b8; font-size: 13px; }
.empty-state strong { display: block; color: #6f7d94; font-size: 16px; margin-bottom: 6px; }

.typing-indicator {
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 24px 2px;
  font-size: 10px;
  color: #9aa7bb;
  background: var(--chat-bg);
}
.typing-indicator.hidden { display: none; }
.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots i {
  width: 4px; height: 4px; border-radius: 50%; background: #a9b6cb;
  animation: blink 1.1s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }


.mention-menu {
  position: absolute;
  left: clamp(16px, 5vw, 54px);
  bottom: 92px;
  width: 230px;
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e3eaf7;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(34, 58, 102, .16);
  padding: 6px;
  z-index: 18;
}
.mention-menu.hidden { display: none; }
.mention-item {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 8px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  color: #2a3548;
  font-size: 13px;
}
.mention-item:hover, .mention-item.active { background: #edf3ff; }
.mention-item .avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 10px; }
.mention-empty { padding: 12px; color: #9aa6b9; font-size: 12px; text-align: center; }
@media (max-width: 800px) {
  .mention-menu { left: 12px; bottom: 86px; width: 210px; }
}
.composer {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 12px clamp(12px, 3.5vw, 40px) max(12px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,.93); border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.composer-tools { display: flex; gap: 2px; }
.tool-btn { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 11px; color: #7e8ba1; display: grid; place-items: center; }
.tool-btn:hover { background: #f0f4fd; color: var(--blue); }
.tool-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.input-wrap { flex: 1; min-width: 0; background: #f4f7fc; border: 1px solid transparent; border-radius: 15px; padding: 0 13px; height: 42px; display: flex; align-items: center; transition: border-color .18s, background .18s; }
.input-wrap:focus-within { background: #fff; border-color: #cfdcff; box-shadow: 0 0 0 3px rgba(79,124,255,.07); }
.input-wrap input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 13px; color: var(--ink); }
.input-wrap input::placeholder { color: #aab4c6; }
.send-btn { border: 0; height: 40px; padding: 0 17px; border-radius: 13px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .03em; box-shadow: 0 7px 16px rgba(79,124,255,.24); transition: background .18s, transform .15s; }
.send-btn:hover { background: var(--blue-dark); }
.send-btn:active { transform: scale(.97); }

/* ---------- overlay ---------- */

.life-sheet { width: min(480px, 100%); max-height: min(82vh, 720px); display: flex; flex-direction: column; }
.life-sub { margin: -4px 0 12px; font-size: 11px; color: #9aa6b9; }
.life-list { overflow: auto; display: flex; flex-direction: column; gap: 9px; padding: 2px 1px 8px; }
.life-item { border: 1px solid #e8eef9; background: #f8faff; border-radius: 15px; padding: 12px 13px; }
.life-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.life-item-title { font-size: 14px; font-weight: 700; color: #2c3850; }
.life-item-time { font-size: 11px; color: #8f9bb0; white-space: nowrap; }
.life-item-meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; font-size: 10px; color: #9aa6b9; }
.life-chip { border-radius: 999px; padding: 2px 7px; background: #edf2ff; color: #5d79c9; }
.life-chip.home { background: #eef8f1; color: #3f9062; }
.life-empty { padding: 28px 10px; text-align: center; color: #9aa6b9; font-size: 12px; }
.overlay { position: fixed; inset: 0; background: rgba(19,30,52,.28); backdrop-filter: blur(4px); display: grid; place-items: end center; z-index: 30; }
.sheet { width: min(430px, 100%); background: #fff; border-radius: 26px 26px 0 0; padding: 18px 20px max(22px, env(safe-area-inset-bottom)); box-shadow: 0 -20px 60px rgba(26,44,82,.18); animation: sheetIn .25s ease both; }
@keyframes sheetIn { from { transform: translateY(20px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.sheet-head strong { font-size: 16px; }
.sheet-head .icon-btn { font-size: 22px; line-height: 1; }
.profile-main { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 4px 0 18px; }
.big-avatar { width: 86px; height: 86px; flex-basis: 86px; font-size: 28px; box-shadow: 0 10px 26px rgba(57,89,160,.18); }
.soft-btn { border: 1px solid #dbe5fa; background: #f4f7ff; color: #4d6fd6; border-radius: 11px; padding: 8px 14px; font-size: 12px; font-weight: 700; }
.soft-btn:hover { background: #eaf0ff; }
.muted { color: #9aa6ba; font-size: 10px; }
.profile-field { margin-top: 2px; }
.text-btn { width: 100%; border: 0; background: transparent; padding: 12px; margin-top: 8px; border-radius: 12px; font-size: 12px; color: #8a96aa; }
.text-btn:hover { background: #f6f8fc; }
.text-btn.danger { color: #d06070; }
.sheet-note { margin: 8px 0 0; text-align: center; font-size: 10px; color: #a7b1c1; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 14px);
  background: rgba(28,41,66,.9); color: #fff; padding: 9px 15px; border-radius: 999px;
  font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10001;
  white-space: nowrap; max-width: 86vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .app-view { display: block; height: 100%; }
  .sidebar { height: 100%; border-right: 0; }
  .chat-pane {
    position: fixed; inset: 0; z-index: 20;
    transform: translateX(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
  }
  .app-view.chat-open .chat-pane { transform: translateX(0); }
  .back-btn { display: grid; }
  .chat-head { height: 64px; flex-basis: 64px; padding: 0 8px; }
  .chat-head .avatar { width: 38px; height: 38px; flex-basis: 38px; }
  .messages { padding: 16px 12px 24px; }
  .msg-row { max-width: 88%; }
  .msg-row .avatar { width: 30px; height: 30px; flex-basis: 30px; }
  .bubble { font-size: 13.5px; }
  
.mention-menu {
  position: absolute;
  left: clamp(16px, 5vw, 54px);
  bottom: 92px;
  width: 230px;
  max-height: 240px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e3eaf7;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(34, 58, 102, .16);
  padding: 6px;
  z-index: 18;
}
.mention-menu.hidden { display: none; }
.mention-item {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 8px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  color: #2a3548;
  font-size: 13px;
}
.mention-item:hover, .mention-item.active { background: #edf3ff; }
.mention-item .avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 10px; }
.mention-empty { padding: 12px; color: #9aa6b9; font-size: 12px; text-align: center; }
@media (max-width: 800px) {
  .mention-menu { left: 12px; bottom: 86px; width: 210px; }
}
.composer { gap: 3px; padding-left: 6px; padding-right: 8px; }
  .composer-tools .tool-btn { width: 32px; height: 34px; }
  .composer-tools .tool-btn svg { width: 19px; height: 19px; }
  .input-wrap { height: 40px; padding: 0 10px; }
  .send-btn { padding: 0 13px; height: 38px; }
  .overlay { place-items: end center; }
}

@media (max-width: 390px) {
  /* 2026-11-18：表情按鈕不再隱藏（手機也要有） */
  .send-btn { padding: 0 11px; }
  .sidebar-top { padding-top: 16px; }
}

















/* 2026-11-18 姐姐機：表情包面板（底部彈出） */
.sticker-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9998;
  background: #f7f8fa; border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(30, 50, 90, .16);
  max-height: 52vh; display: flex; flex-direction: column;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
}
.sticker-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 10px; }
.sticker-head strong { font-size: 14px; color: #2b3750; }
.sticker-close { border: 0; background: transparent; font-size: 22px; line-height: 1; color: #8b95a5; cursor: pointer; }
.sticker-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  overflow-y: auto; padding-bottom: 6px;
}
.sticker-cell { position: relative; aspect-ratio: 1; background: #fff; border-radius: 12px; overflow: hidden; }
.sticker-cell img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.sticker-del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
}
.sticker-add {
  aspect-ratio: 1; border: 1px dashed #c9d6ec; border-radius: 12px;
  background: #fff; color: #9aa6b9; font-size: 26px; cursor: pointer;
}
.sticker-empty { grid-column: 1 / -1; text-align: center; color: #9aa6b9; font-size: 12px; padding: 14px 0; }