/* 简洁、独立设计的界面：不使用任何第三方风格与品牌元素 */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  color: #222;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 登录页 ---------- */
#login-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 380px; background: #fff; border: 1px solid #e2e5ea;
  border-radius: 8px; padding: 32px 28px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
h1 { font-size: 24px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.subtitle { text-align: center; color: #888; font-size: 13px; margin-bottom: 24px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #d4d8de;
  border-radius: 6px; font-size: 14px; outline: none; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #5b7cfa; }
.hint { font-size: 12px; color: #999; margin-top: 6px; line-height: 1.5; }

.btn-row { display: flex; gap: 10px; }
button {
  padding: 10px; border: none; border-radius: 6px; font-size: 14px; cursor: pointer;
}
button.primary { background: #5b7cfa; color: #fff; flex: 1; }
button.primary:hover { background: #4769e8; }
button.secondary { background: #eef0f4; color: #333; flex: 1; }
button.secondary:hover { background: #e2e6ed; }
button.primary.small, button.secondary.small { padding: 8px 16px; flex: 0 0 auto; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

#result {
  margin-top: 16px; font-size: 13px; text-align: center;
  min-height: 18px; white-space: pre-line; word-break: break-all;
}
#result.error { color: #d33; }
#result.ok { color: #1a7f37; }

/* ---------- 主界面 ---------- */
#main-page { display: none; height: 100vh; flex-direction: column; }

header {
  height: 48px; background: #fff; border-bottom: 1px solid #e2e5ea;
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
header .brand { font-size: 18px; font-weight: 600; }
header .current-user { font-size: 13px; color: #666; flex: 1; }
header button.logout { background: #eef0f4; color: #333; padding: 6px 14px; font-size: 13px; }

/* Tab 栏 */
.tabs {
  height: 42px; background: #fff; border-bottom: 1px solid #e2e5ea;
  display: flex; padding: 0 16px; gap: 4px; align-items: center;
}
.tab-btn {
  background: transparent; color: #555; padding: 8px 18px; border-radius: 6px;
}
.tab-btn:hover { background: #f0f2f6; }
.tab-btn.active { background: #e9edfd; color: #3a56d8; font-weight: 600; }

.layout { flex: 1; display: flex; min-height: 0; }

/* Tab 页面 */
.tab-page { display: none; flex: 1; min-width: 0; min-height: 0; }
.tab-page.active { display: flex; }
#page-chat.active, #page-contacts.active { flex-direction: column; }
#page-todo.active, #page-me.active { flex-direction: column; }

/* 联系人页 */
.contacts-page {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  background: #fff;
}
.contacts-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; font-size: 13px; color: #888;
  border-bottom: 1px solid #e2e5ea; flex-shrink: 0;
}
.add-friend-btn {
  background: #3a56d8; color: #fff; border: none; border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.add-friend-btn:hover { background: #2f46b8; }
#contact-list { flex: 1; overflow-y: auto; }
.contact-item {
  padding: 14px 16px; font-size: 14px; cursor: pointer;
  border-bottom: 1px solid #f0f2f5; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.contact-item:hover { background: #f6f7fb; }
.contact-item.active { background: #e9edfd; color: #3a56d8; }
.contact-item.pending-out { color: #999; cursor: default; }
.contact-item.pending-in { color: #555; }
.contact-item .contact-actions { display: flex; gap: 8px; margin-top: 8px; }
.reject-friend-btn {
  background: #fff; color: #c0392b; border: 1px solid #dcdde0;
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.reject-friend-btn:hover { background: #fdf1f1; }

/* 全局非阻塞提示 */
.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78); color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 13px; z-index: 9999;
  display: none; max-width: 80%; text-align: center; pointer-events: none;
}

section.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  height: 46px; background: #fff; border-bottom: 1px solid #e2e5ea;
  display: flex; align-items: center; padding: 0 16px; font-size: 14px; font-weight: 600;
}
.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: #999; font-size: 14px;
}
.messages {
  flex: 1; overflow-y: auto; padding: 16px; background: #f9fafc;
}
.msg-row { margin-bottom: 12px; }
.msg-row .msg-meta { font-size: 11px; color: #999; margin-bottom: 3px; }
.msg-row.mine .msg-meta { text-align: right; }
.msg-row .bubble {
  display: inline-block; max-width: 70%; padding: 9px 12px;
  border-radius: 8px; font-size: 14px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
}
.msg-row.theirs .bubble { background: #fff; border: 1px solid #e2e5ea; }
.msg-row.mine .bubble { background: #5b7cfa; color: #fff; float: right; }
.msg-row.mine::after { content: ""; display: block; clear: both; }

.bubble.voice { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.voice-play {
  background: #fff; border: 1px solid #d4d8de; border-radius: 14px;
  padding: 4px 14px; font-size: 13px; color: #3a56d8;
}
.msg-row.mine .voice-play { background: #eef1fe; }
.voice-dur { font-size: 13px; color: #666; font-variant-numeric: tabular-nums; }
.msg-row.mine .voice-dur { color: #e8ecff; }

/* 输入区 */
.input-row {
  display: flex; gap: 10px; padding: 12px 16px; align-items: center;
  background: #fff; border-top: 1px solid #e2e5ea;
}
.input-row input[type="text"] {
  flex: 1; padding: 10px; border: 1px solid #d4d8de; border-radius: 6px;
  font-size: 14px; outline: none; min-width: 0;
}
.input-row input[type="text"]:focus { border-color: #5b7cfa; }
.input-row button.send { background: #5b7cfa; color: #fff; padding: 10px 22px; }
.input-row button.send:hover { background: #4769e8; }

.mic-btn {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  background: #eef0f4; color: #555; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.mic-btn:hover { background: #e2e6ed; }
.mic-btn.recording { background: #fdecec; color: #d33; }

.input-area { flex: 1; display: flex; align-items: center; min-width: 0; }

.rec-state { display: none; align-items: center; gap: 8px; width: 100%; }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #e33;
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }
.rec-timer {
  font-size: 16px; font-weight: 600; color: #d33;
  font-variant-numeric: tabular-nums;
}
.rec-hint { color: #999; font-size: 12px; }

.preview-state { display: none; align-items: center; gap: 12px; width: 100%; }
.preview-state canvas {
  background: #fff; border: 1px solid #e2e5ea; border-radius: 6px;
}
.preview-state .pv-dur { font-size: 13px; color: #555; font-variant-numeric: tabular-nums; }
.preview-state button.pv-send { background: #5b7cfa; color: #fff; padding: 8px 16px; }
.preview-state button.pv-send:hover { background: #4769e8; }
.preview-state button.pv-cancel { background: #eef0f4; color: #333; padding: 8px 16px; }
.preview-state button.pv-cancel:hover { background: #e2e6ed; }

/* ---------- 日程页 ---------- */
.todo-toolbar {
  display: flex; gap: 10px; padding: 12px 16px; align-items: center;
  background: #fff; border-bottom: 1px solid #e2e5ea;
}
.todo-toolbar select {
  padding: 8px 10px; border: 1px solid #d4d8de; border-radius: 6px;
  font-size: 14px; outline: none; flex: 0 0 auto;
}
.todo-body { flex: 1; overflow-y: auto; padding: 16px; background: #f9fafc; }
#todo-list { list-style: none; }
.todo-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: #fff; border: 1px solid #e2e5ea; border-radius: 8px;
  margin-bottom: 10px; cursor: pointer;
}
.todo-item:hover { border-color: #c6cde0; }
.todo-item.done .todo-title { text-decoration: line-through; color: #999; }
.todo-check { width: 18px; height: 18px; cursor: pointer; flex: 0 0 18px; }
.todo-main { flex: 1; min-width: 0; }
.todo-title { font-size: 14px; word-break: break-all; }
.todo-sub { font-size: 12px; color: #888; margin-top: 3px; word-break: break-all; }
.todo-pri { flex: 0 0 auto; font-size: 12px; padding: 2px 8px; border-radius: 10px; color: #fff; }
.pri-1 { background: #d33; }
.pri-2 { background: #d98500; }
.pri-3 { background: #1a7f37; }
.todo-src { flex: 0 0 auto; font-size: 12px; color: #666; max-width: 140px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#todo-empty { text-align: center; color: #999; padding: 40px 0; }

/* ---------- 我 页 ---------- */
.me-page { align-items: center; justify-content: flex-start; padding: 24px; overflow-y: auto; }
.me-card {
  width: 320px; background: #fff; border: 1px solid #e2e5ea; border-radius: 10px;
  padding: 28px 24px; text-align: center;
}
.me-avatar {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px;
  background: #5b7cfa; color: #fff; font-size: 32px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.me-username { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.me-server { font-size: 12px; color: #888; margin-bottom: 16px; }
.me-status {
  display: inline-block; padding: 6px 16px; border-radius: 16px;
  background: #e9edfd; color: #3a56d8; font-size: 14px; cursor: pointer;
  margin-bottom: 10px;
}
.me-status.none { background: #eef0f4; color: #888; }
.me-link { font-size: 13px; color: #666; margin-bottom: 16px; min-height: 18px; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 100;
  display: none; align-items: center; justify-content: center;
}
.overlay.show { display: flex; }
.modal {
  width: 380px; max-width: 92vw; background: #fff; border-radius: 10px;
  padding: 22px 20px;
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal .btn-row { margin-top: 18px; }
.radio-row { display: flex; gap: 16px; }
.radio-row label { font-size: 14px; display: flex; align-items: center; gap: 5px; cursor: pointer; }

.recv-text { font-size: 14px; color: #333; line-height: 1.6; word-break: break-all; }

/* 右键菜单 */
.ctx-menu {
  position: fixed; z-index: 200; background: #fff; border: 1px solid #e2e5ea;
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  display: none; min-width: 130px; padding: 4px 0;
}
.ctx-menu.show { display: block; }
.ctx-item { padding: 9px 16px; font-size: 14px; cursor: pointer; }
.ctx-item:hover { background: #f0f2f6; }
.ctx-item.danger { color: #d33; }

/* ==================== 液态玻璃（Liquid Glass）主题 ==================== */

body {
  background: linear-gradient(135deg, #dfe9ff 0%, #f7e8f5 45%, #e2f0ff 100%) fixed;
}
#main-page { background: transparent; }
header, .tabs {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
}

/* 登录卡片 */
.login-card {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 20px 50px rgba(30, 40, 80, 0.18);
  border-radius: 18px;
}

/* 首页：左窄栏选择聊天对象 + 右侧聊天框 */
#page-chat.active { flex-direction: row; }
#home-panel {
  width: 220px; flex-shrink: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid rgba(255, 255, 255, 0.5);
}
.panel-title {
  padding: 12px 16px; font-size: 13px; color: #667; font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5); flex-shrink: 0;
}
#home-contact-list { flex: 1; overflow-y: auto; }

/* 聊天区玻璃化 */
.chat {
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.chat-header {
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}
.messages { background: transparent; }
.input-row input[type="text"] {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(255, 255, 255, 0.6);
}

/* 联系人页：两个纵向长按钮 */
.contacts-page {
  background: rgba(255, 255, 255, 0.30);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.contacts-nav {
  display: flex; flex-direction: column; gap: 12px; padding: 16px;
  flex-shrink: 0;
}
.contacts-section-btn {
  width: 100%; padding: 16px 18px; font-size: 15px; text-align: left;
  display: flex; justify-content: space-between; align-items: center;
}
.contacts-section-btn.active {
  background: rgba(58, 86, 216, 0.18); color: #3a56d8;
  box-shadow: 0 10px 26px rgba(58, 86, 216, 0.22);
}
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: #ff5b5b; color: #fff; font-size: 12px; line-height: 20px;
  text-align: center; display: inline-block;
}
.badge:empty { display: none; }

/* 悬浮添加好友按钮（FAB） */
.fab {
  position: fixed; right: 28px; bottom: 28px;
  width: 54px; height: 54px; border-radius: 50%;
  font-size: 26px; font-weight: 600; color: #3a56d8;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 12px 30px rgba(58, 86, 216, 0.32);
}
.fab:hover { transform: translateY(-3px); }

/* 列表空态 */
.list-empty {
  padding: 32px 16px; text-align: center; color: #889; font-size: 13px;
}

/* 联系人条目微调 */
.contact-item:hover { background: rgba(255, 255, 255, 0.5); }
.contact-item.active { background: rgba(58, 86, 216, 0.16); color: #3a56d8; }

/* 消息气泡 */
.msg-row.theirs .bubble {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.msg-row.mine .bubble { background: rgba(58, 86, 216, 0.65); color: #fff; }
.msg-row.mine .voice-play { background: rgba(255, 255, 255, 0.25); }

/* 弹窗 */
.overlay {
  background: rgba(20, 30, 60, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 20px 50px rgba(20, 30, 60, 0.22);
  border-radius: 16px;
}

/* 液态玻璃按钮（悬浮感，覆盖旧实色样式） */
button.primary, button.secondary, button.primary.small, button.secondary.small,
header button.logout,
.input-row button.send,
.tab-btn, .mic-btn, .add-friend-btn, .reject-friend-btn,
.msg-row .voice-play, .pv-send, .pv-cancel, .contacts-section-btn {
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 6px 18px rgba(90, 110, 180, 0.16);
  color: #3a4a6b;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
button.primary:hover, button.secondary:hover, header button.logout:hover,
.input-row button.send:hover, .tab-btn:hover, .mic-btn:hover,
.add-friend-btn:hover, .reject-friend-btn:hover, .msg-row .voice-play:hover,
.pv-send:hover, .pv-cancel:hover, .contacts-section-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(90, 110, 180, 0.24);
}
button.primary, .input-row button.send { background: rgba(58, 86, 216, 0.22); color: #fff; }
.tab-btn.active { background: rgba(58, 86, 216, 0.18); color: #3a56d8; font-weight: 600; }
.mic-btn.recording { background: rgba(221, 51, 51, 0.2); color: #d33; }
.reject-friend-btn { color: #c0392b; }
.ctx-menu {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 12px 32px rgba(20, 30, 60, 0.18);
  border-radius: 10px;
}
.ctx-item:hover { background: rgba(58, 86, 216, 0.1); }
