* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #eef2f6;
  color: #1f2329;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* 真实 QQ 头像填满各自的圆角框 */
.me-avatar img, .peer-avatar img, .conv-avatar img, .row .avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* ── 登录 ── */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #dff0ff 0%, transparent 60%),
              radial-gradient(900px 500px at 90% 100%, #ffe6f0 0%, transparent 55%),
              #f7fafd;
}
.login-card {
  width: 300px; padding: 30px 26px 24px; background: #fff; border-radius: 22px;
  box-shadow: 0 24px 60px rgba(31, 35, 41, .13); text-align: center;
}
.login-title { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.login-sub { color: #8a9099; font-size: 13px; margin: 6px 0 18px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1.5px solid #e3e9f0; border-radius: 12px;
  font-size: 15px; outline: none; background: #f7f9fb; transition: .15s;
}
.login-card input:focus { border-color: #12b7f5; background: #fff; box-shadow: 0 0 0 3px rgba(18,183,245,.12); }
.login-card button {
  width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, #22c1ff, #0ea5e9); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; box-shadow: 0 6px 16px rgba(18,183,245,.28);
}
.login-card button:active { transform: translateY(1px); }
.login-err { color: #e5484d; font-size: 12px; height: 16px; margin-top: 8px; }

/* ── 主体 ── */
.app { display: flex; height: 100%; }

.sidebar {
  width: 280px; flex: 0 0 280px; background: #f8fafc; border-right: 1px solid #e6ebf1;
  display: flex; flex-direction: column;
}
.sidebar-head {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px;
}
.me-avatar {
  width: 38px; height: 38px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(135deg, #7dd3fc, #0ea5e9); color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(14,165,233,.28);
}
.me-name { font-weight: 700; font-size: 15px; }

.search {
  margin: 0 14px 10px; display: flex; align-items: center; gap: 8px;
  background: #eef2f7; border-radius: 10px; padding: 8px 12px; color: #98a1ac; font-size: 13px;
}
.search input {
  border: 0; background: none; outline: none; flex: 1; font-size: 13px; color: #1f2329;
}

.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.conv {
  display: flex; gap: 11px; align-items: center; padding: 11px 10px; border-radius: 14px; cursor: pointer;
  transition: background .15s;
}
.conv:hover { background: #eef4f9; }
.conv.active { background: #e3f2fd; }
.conv-avatar {
  width: 46px; height: 46px; border-radius: 14px; overflow: hidden; flex: 0 0 46px; display: grid; place-items: center;
  background: linear-gradient(135deg, #ffd6e7, #ff9ec4); color: #a3325c; font-weight: 700; font-size: 17px;
  box-shadow: 0 2px 8px rgba(255,158,196,.3);
}
.conv-info { min-width: 0; flex: 1; }
.conv-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-title { font-size: 14.5px; font-weight: 600; }
.conv-time { font-size: 11px; color: #a5adb8; flex: 0 0 auto; }
.conv-last {
  font-size: 12.5px; color: #8a9099; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #f4f7fa; position: relative; }
.chat::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(700px 380px at 15% 0%, rgba(186,230,253,.35), transparent 65%),
    radial-gradient(600px 360px at 100% 100%, rgba(253,232,240,.45), transparent 60%);
}
.chat > * { position: relative; }

.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid #e8edf2;
}
.back { display: none; border: 0; background: none; font-size: 24px; line-height: 1; color: #5a626c; padding: 0 8px 0 0; cursor: pointer; }
.peer-avatar {
  width: 38px; height: 38px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(135deg, #ffd6e7, #ff9ec4); color: #a3325c; font-weight: 700;
  box-shadow: 0 2px 8px rgba(255,158,196,.35);
}
.peer-meta { flex: 1; min-width: 0; }
.peer-name { font-size: 15px; font-weight: 700; }
.peer-status { font-size: 11px; color: #22a06b; margin-top: 1px; }
.peer-status.busy { color: #e08a00; }
.head-actions button {
  border: 0; background: #f1f5f9; color: #7b8494; font-size: 12px; padding: 7px 12px;
  border-radius: 9px; cursor: pointer; transition: .15s;
}
.head-actions button:hover { background: #e6edf5; color: #4b5563; }

.messages { flex: 1; overflow-y: auto; padding: 18px 16px 8px; scroll-behavior: smooth; }
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: #d5dde6; border-radius: 3px; }

.day { text-align: center; margin: 12px 0; }
.day span {
  font-size: 11px; color: #9aa3ae; background: rgba(255,255,255,.75);
  padding: 3px 10px; border-radius: 10px; backdrop-filter: blur(4px);
}

.row { display: flex; gap: 9px; margin-bottom: 14px; align-items: flex-end; }
.row.me { flex-direction: row-reverse; }
.row .avatar {
  width: 32px; height: 32px; border-radius: 8px; overflow: hidden; flex: 0 0 32px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; margin-bottom: 16px;
}
.row.her .avatar { background: linear-gradient(135deg, #ffd6e7, #ff9ec4); color: #a3325c; }
.row.me .avatar { background: linear-gradient(135deg, #7dd3fc, #0ea5e9); }
.bubble-wrap { max-width: min(72%, 540px); }
.bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; background: #fff;
  box-shadow: 0 2px 6px rgba(31,35,41,.06); border-top-left-radius: 6px;
}
.row.me .bubble {
  background: linear-gradient(135deg, #2ec4ff, #0ea5e9); color: #fff;
  border-top-left-radius: 16px; border-top-right-radius: 6px;
  box-shadow: 0 4px 12px rgba(14,165,233,.28);
}
.time { font-size: 10px; color: #a9b1bb; margin-top: 5px; text-align: left; }
.row.me .time { text-align: right; }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #b8c2cd; display: block;
  animation: bounce 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.sys { text-align: center; margin: 14px 0; }
.sys span {
  font-size: 11.5px; color: #8f98a3; background: rgba(255,255,255,.7);
  padding: 4px 12px; border-radius: 12px;
}

.composer {
  display: flex; gap: 10px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-top: 1px solid #e8edf2;
  align-items: flex-end;
}
.composer textarea {
  flex: 1; resize: none; border: 1.5px solid #e6ebf1; border-radius: 18px; padding: 11px 15px;
  font-size: 15px; font-family: inherit; line-height: 1.45; max-height: 132px; outline: none;
  background: #f6f8fb; transition: .15s;
}
.composer textarea:focus { border-color: #7dd3fc; background: #fff; box-shadow: 0 0 0 3px rgba(18,183,245,.1); }
.send {
  border: 0; border-radius: 50%; width: 44px; height: 44px; flex: 0 0 44px;
  background: linear-gradient(135deg, #2ec4ff, #0ea5e9); color: #fff; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 6px 16px rgba(14,165,233,.3);
  transition: .15s;
}
.send:hover { filter: brightness(1.05); }
.send:disabled { background: #c9d6e2; box-shadow: none; cursor: default; }
.send svg { width: 20px; height: 20px; fill: #fff; }

@media (max-width: 720px) {
  .sidebar { position: fixed; inset: 0; width: 100%; flex: none; z-index: 5; }
  .sidebar.hide { display: none; }
  .back { display: block; }
  .chat { width: 100%; }
  .bubble-wrap { max-width: 80%; }
  .messages { padding: 14px 12px 6px; }
}

/* 她的日记 —— 2026-11-28 新增板块
   数据来自 /api/diaries（记忆巩固每晚写进 data/diaries.jsonl 的那份，只追加、历史全留）。
   配色沿用聊天区的浅色系，桌面从右侧滑出，手机上铺满整屏。 */
.diary-mask {
  position: fixed; inset: 0; background: rgba(20, 26, 33, .32);
  backdrop-filter: blur(2px); z-index: 20;
  animation: diaryFade .18s ease-out;
}
@keyframes diaryFade { from { opacity: 0; } to { opacity: 1; } }

.diary-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: #f7fafd; z-index: 21; display: flex; flex-direction: column;
  box-shadow: -18px 0 50px rgba(31, 35, 41, .16);
  animation: diarySlide .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes diarySlide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.diary-head {
  position: relative; padding: 18px 18px 14px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid #e8edf2;
}
.diary-title { font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.diary-sub { font-size: 11.5px; color: #98a1ac; margin-top: 3px; }
.diary-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border: 0;
  border-radius: 50%; background: #eef3f8; color: #7b8494; font-size: 17px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; transition: .15s;
}
.diary-close:hover { background: #e2eaf3; color: #4b5563; }

.diary-list { flex: 1; overflow-y: auto; padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); }
.diary-list::-webkit-scrollbar { width: 6px; }
.diary-list::-webkit-scrollbar-thumb { background: #d5dde6; border-radius: 3px; }

.diary-card {
  background: #fff; border-radius: 16px; padding: 14px 16px 12px; margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(31, 35, 41, .055); border: 1px solid rgba(232, 237, 242, .9);
}
.diary-card-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.diary-date {
  font-size: 11px; color: #0ea5e9; background: #e8f6fe; padding: 2px 8px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.diary-card-title { font-size: 14.5px; font-weight: 700; color: #1f2329; }
.diary-text {
  margin-top: 9px; font-size: 14px; line-height: 1.75; color: #384049; white-space: pre-wrap;
}
.diary-meta { margin-top: 9px; font-size: 10.5px; color: #a9b1bb; text-align: right; }
.diary-empty { text-align: center; color: #98a1ac; font-size: 13px; padding: 54px 20px; line-height: 1.9; }
.diary-loading { text-align: center; color: #a9b1bb; font-size: 13px; padding: 40px 0; }

@media (max-width: 720px) {
  .diary-panel { width: 100%; max-width: 100%; }
}
.diary-month { font-size: 11.5px; color: #98a1ac; padding: 2px 4px 8px; letter-spacing: .4px; }

/* 日记筛选（全部 / 本周） */
.diary-filters {
  display: flex; gap: 6px; margin-top: 10px;
}
.diary-filters button {
  border: 0; background: #eef3f8; color: #7b8494; font-size: 12px; padding: 5px 12px;
  border-radius: 9px; cursor: pointer; transition: .15s;
}
.diary-filters button:hover { background: #e2eaf3; color: #4b5563; }
.diary-filters button.on {
  background: linear-gradient(135deg, #2ec4ff, #0ea5e9); color: #fff;
  box-shadow: 0 3px 10px rgba(14, 165, 233, .25);
}

/* 多角色（2026-11-28）：群聊里的发言人名字 + 首字母头像 */
.row .avatar.letter {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
}
.bubble-name {
  font-size: 11px;
  color: #98a1ac;
  margin: 0 0 4px 6px;
  letter-spacing: .3px;
}
.row.me .bubble-name {
  text-align: right;
  margin: 0 6px 4px 0;
}

/* 日记作者标签（多角色） */
.diary-who {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ff9ec4, #ff7aa8);
  padding: 2px 8px;
  border-radius: 8px;
  letter-spacing: .3px;
}

/* ── 未读小红点 + 续行气泡（2026-11-29） ── */

/* QQ 那种红点：贴在会话头像右上角，显示未读数 */
.conv-avatar { position: relative; }
.conv-avatar .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff3b30;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(255, 59, 48, .45);
  border: 1.5px solid #fff;
  box-sizing: content-box;
}

/* 有未读时，最后一条预览加粗一点（QQ 也是这么区分） */
.conv-last.unread { color: #1f2329; font-weight: 600; }

/* 长回复拆成多颗气泡时，后面的几颗不重复显示头像/名字，只对齐正文 */
.row.cont .avatar { visibility: hidden; }
.row.cont .bubble-name { display: none; }
.row.cont .bubble { margin-top: 2px; }

/* ── 表情包气泡（2026-11-29）：气泡里只放一张图，不再套文字背景 ── */
.bubble.sticker {
  background: transparent;
  padding: 2px;
  box-shadow: none;
  max-width: 140px;
}
.bubble.sticker img {
  display: block;
  width: 120px;
  height: auto;
  max-height: 140px;
  object-fit: contain;
  border-radius: 8px;
}
.row.cont .bubble.sticker { margin-top: 4px; }
