/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--card-border-blue);
  z-index: var(--z-navbar);
  gap: 8px;
}
.navbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  color: var(--deep-blue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.navbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--soft-blue);
  transition: background 0.15s;
}
.navbar-btn:active { background: rgba(176, 224, 255, 0.2); }
.svg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  color: currentColor;
}
.svg-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.svg-icon svg path,
.svg-icon svg circle,
.svg-icon svg rect {
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Tabbar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-h);
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--border);
  z-index: var(--z-tabbar);
}
.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-hint);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.tabbar-item .tab-icon { font-size: 22px; }
.tabbar-item.active { color: var(--primary); }
.tabbar-item:active { background: var(--bg-active); }

/* Avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f7fbff, #dff1ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--deep-blue);
  overflow: hidden;
  flex-shrink: 0;
  border: none;
  box-shadow: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 36px; height: 36px; font-size: 15px; }
.avatar-lg { width: 56px; height: 56px; font-size: 24px; }
.avatar-xl { width: 72px; height: 72px; font-size: 32px; }

/* Chat Bubble */
.bubble-row {
  display: flex;
  gap: 10px;
  padding: 3px 10px;
  max-width: 100%;
  align-items: flex-start;
}
.bubble-row.self { flex-direction: row-reverse; }
.bubble-wrap { max-width: 78%; display: flex; flex-direction: column; }
.bubble-row.self .bubble-wrap { align-items: flex-end; }
.bubble-avatar-slot {
  width: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
}
.bubble-sender {
  font-size: var(--font-xs);
  color: var(--soft-blue);
  margin-bottom: 4px;
  padding: 0 6px;
}
.bubble {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}
.bubble-row:not(.self) .bubble {
  background: var(--bubble-other);
  color: var(--bubble-other-text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.bubble-row.self .bubble {
  background: var(--bubble-self);
  color: var(--bubble-self-text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.bubble-time {
  font-size: var(--font-xs);
  color: #6d92b5;
  margin-top: 4px;
  padding: 0 6px;
}
.bubble-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.bubble-reaction {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-size: var(--font-xs);
}
.bubble-reply-ref {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  border-left: 2px solid var(--primary);
}
.bubble.recalled {
  opacity: 0.5;
  font-style: italic;
  font-size: var(--font-sm);
}

/* System message */
.system-msg {
  text-align: center;
  font-size: var(--font-xs);
  color: var(--text-hint);
  padding: 8px 24px;
}

/* Chat input bar */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-top: 1px solid #ebedf0;
}
.chat-input {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  padding: 10px 14px;
  border-radius: 28px;
  border: 1px solid #dde2e8;
  background: #ffffff;
  resize: none;
  outline: none;
  font-size: 14px;
  line-height: 1.4;
  color: #1f2937;
  caret-color: #3b82f6;
}
.chat-input:focus { border-color: var(--primary); }
.chat-input::placeholder { color: #7f9fbf; }
.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #5f8db0;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(95, 141, 176, 0.5);
}
.chat-send-btn:active { opacity: 0.8; }

/* QQ-like cleaner chat layout */
.chat-page .bubble-row {
  gap: 12px;
  padding: 6px 12px;
}
.chat-page .bubble-avatar-slot {
  width: 44px;
}
.chat-page .avatar {
  width: 44px;
  height: 44px;
  border: none;
  box-shadow: none;
}
.chat-page .bubble-wrap {
  max-width: min(78%, 520px);
}
/*
 * 自己侧：flex-end 整行贴右；order 让气泡在左、头像在右（与 gap 一致）。
 * 气泡列不 flex 放大（0 1 auto），宽=max(内容,max-width 帽)；内部 flex-end → 图/文右缘对齐。
 */
.chat-page .bubble-row.self {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 12px;
}
.chat-page .bubble-row.self .bubble-avatar-slot {
  order: 2;
  flex: 0 0 44px;
  width: 44px;
}
.chat-page .bubble-row.self .bubble-wrap {
  order: 1;
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(78%, 520px);
  box-sizing: border-box;
}
.chat-page .bubble {
  border-radius: 14px;
}
.chat-tools-row {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  overflow-x: auto;
}
.chat-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: var(--font-xs);
  color: var(--text-secondary);
  min-width: 48px;
}
.chat-tool-btn .tool-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, #ffffff, #e8f4ff);
  border: 1px solid #cde7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--soft-blue);
  box-shadow: var(--home-shadow-soft);
}

/* List items */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.list-item:active { background: var(--bg-active); }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-size: var(--font-md); font-weight: 500; }
.list-item-subtitle {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item-right {
  font-size: var(--font-xs);
  color: var(--text-hint);
  text-align: right;
  flex-shrink: 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn 0.2s;
}
.modal-sheet {
  width: 100%;
  max-height: 85vh;
  background: var(--bg-card-solid);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}
.modal-sheet-center {
  align-items: center;
  padding: 24px;
}
.modal-sheet-center .modal-sheet {
  width: 85%;
  max-width: 360px;
  border-radius: var(--radius-xl);
  animation: scaleIn 0.25s ease-out;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: var(--font-lg); font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; max-height: 60vh; }

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--bg-card-solid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 140px;
  z-index: var(--z-context);
  animation: scaleIn 0.15s ease-out;
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: var(--font-md);
  transition: background 0.1s;
}
.context-menu-item:active { background: var(--bg-active); }

/* Toast */
.toast {
  background: var(--bg-card-solid);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-sm);
  animation: scaleIn 0.2s ease-out;
  pointer-events: auto;
}

/* Form controls */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  outline: none;
  font-size: var(--font-md);
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary); }
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  outline: none;
  font-size: var(--font-md);
  min-height: 80px;
  resize: vertical;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: var(--font-md);
  font-weight: 500;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { opacity: 0.8; transform: scale(0.97); }
.btn-primary { background: var(--primary); color: var(--text-inverse); }
.btn-outline { border: 1px solid var(--primary); color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: var(--font-sm); }
.btn-block { width: 100%; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { transform: translateX(20px); }

/* Section */
.section-header {
  font-size: var(--font-sm);
  color: var(--text-hint);
  padding: 16px 16px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Special cards */
.red-packet-card {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 16px;
  min-width: 200px;
}
.transfer-card {
  background: linear-gradient(135deg, var(--orange), #e67e22);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 16px;
  min-width: 200px;
}
.location-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 220px;
  border: 1px solid var(--border);
}
.location-card-map {
  height: 100px;
  background: linear-gradient(135deg, #dfe6e9, #b2bec3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.location-card-info { padding: 8px 12px; }

.link-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 200px;
}
.link-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.link-card-info { flex: 1; min-width: 0; }
.link-card-title { font-size: var(--font-sm); font-weight: 500; }
.link-card-desc { font-size: var(--font-xs); color: var(--text-hint); }
.link-card-source { font-size: var(--font-xs); color: var(--text-hint); margin-top: 2px; }

.voice-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-width: 80px;
}
.voice-msg-wave { display: flex; align-items: center; gap: 2px; }
.voice-msg-wave span {
  width: 3px;
  border-radius: 2px;
  background: currentColor;
  animation: waveAnim 0.8s ease-in-out infinite alternate;
}
.voice-msg-wave span:nth-child(2) { animation-delay: 0.15s; }
.voice-msg-wave span:nth-child(3) { animation-delay: 0.3s; }
@keyframes waveAnim {
  from { height: 6px; }
  to { height: 16px; }
}
.voice-msg-dur { font-size: var(--font-sm); }

/* 独立表情包/纯图：无气泡底色与描边，贴会话背景（类似微信贴纸） */
.chat-sticker-slot {
  display: block;
  width: fit-content;
  max-width: 100%;
  line-height: 0;
}
.chat-sticker {
  display: block;
  width: fit-content;
  max-width: 100%;
  line-height: 0;
}
.chat-sticker-slot .chat-sticker img,
.chat-sticker img {
  display: block;
  max-width: min(100%, 200px);
  max-height: min(44vh, 260px);
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center bottom;
  border: none;
  border-radius: 0;
  box-shadow: none;
  vertical-align: bottom;
}
@media (max-width: 480px) {
  .chat-sticker-slot .chat-sticker img,
  .chat-sticker img {
    max-width: min(100%, 132px);
    max-height: min(30vh, 168px);
  }
}

/* 表情包/纯图：主行不要用 width:100%（会在列里拉满再留白）；与文字气泡一样靠内容宽度 + 外层 bubble-wrap 的 align-items 贴边 */
.bubble-mainline {
  display: flex;
  align-items: center;
}
.bubble-mainline--media {
  display: block;
  width: max-content;
  max-width: 100%;
  min-width: 0;
}
.bubble-mainline--media .blocked-indicator {
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
}

.chat-sticker-picker {
  align-content: start;
}

.chat-sticker-picker .stk-pick {
  border: none;
  background: transparent;
  padding: 4px 2px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  min-width: 0;
}

.chat-sticker-picker .stk-pick-label {
  display: block;
  width: 100%;
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-secondary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-sticker-picker .stk-pick-img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg-card);
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .chat-sticker-picker .stk-pick-img {
    width: 34px;
    height: 34px;
  }
}

/* 淘宝 / 美团 风格「分享购物」卡片 */
.order-share-card {
  min-width: 220px;
  max-width: 280px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  font-size: var(--font-xs);
}
.order-share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-weight: 600;
}
.order-share-brand { font-size: var(--font-sm); }
.order-share-sub { font-size: 10px; opacity: 0.85; font-weight: 500; }
.order-share-body {
  display: flex;
  gap: 10px;
  padding: 0 10px 10px;
}
.order-share-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  flex-shrink: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.5), rgba(0, 0, 0, 0.06));
}
.order-share-main { flex: 1; min-width: 0; }
.order-share-title {
  font-size: var(--font-sm);
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.order-share-price {
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.order-share-price-label { font-size: 10px; opacity: 0.75; }
.order-share-price-num { font-size: var(--font-md); font-weight: 700; }
.order-share-note {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.88;
  line-height: 1.35;
}
.order-share-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 10px;
}
.order-share-linkish {
  color: #1677ff;
  font-weight: 500;
}
.order-share-hint { opacity: 0.55; }

.order-share-card--taobao .order-share-header {
  background: linear-gradient(90deg, #ff5000 0%, #ff7a45 100%);
  color: #fff;
}
.order-share-card--taobao .order-share-sub { color: rgba(255, 255, 255, 0.9); }
.order-share-card--taobao .order-share-thumb {
  background: linear-gradient(145deg, #ffe8dc, #ffcda2);
}
.order-share-card--taobao .order-share-linkish { color: #ff5000; }

.order-share-card--meituan .order-share-header {
  background: linear-gradient(90deg, #ffc300 0%, #ffda44 100%);
  color: #3d2e00;
}
.order-share-card--meituan .order-share-sub { color: rgba(0, 0, 0, 0.5); }
.order-share-card--meituan .order-share-thumb {
  background: linear-gradient(145deg, #fff8dc, #f0e68c);
}
.order-share-card--meituan .order-share-linkish { color: #d19000; }

.order-share-card--jd .order-share-header {
  background: linear-gradient(90deg, #e3393c 0%, #ff6b6b 100%);
  color: #fff;
}
.order-share-card--jd .order-share-sub { color: rgba(255, 255, 255, 0.9); }
.order-share-card--jd .order-share-thumb {
  background: linear-gradient(145deg, #ffe0e0, #f0b0b0);
}
.order-share-card--jd .order-share-linkish { color: #e3393c; }

.order-share-card--pdd .order-share-header {
  background: linear-gradient(90deg, #e02e24 0%, #ff6a59 100%);
  color: #fff;
}
.order-share-card--pdd .order-share-sub { color: rgba(255, 255, 255, 0.9); }
.order-share-card--pdd .order-share-thumb {
  background: linear-gradient(145deg, #ffd6d0, #ffab9d);
}
.order-share-card--pdd .order-share-linkish { color: #e02e24; }

.order-share-card--generic .order-share-header {
  background: linear-gradient(90deg, #5b8def 0%, #7ec8f5 100%);
  color: #fff;
}
.order-share-card--generic .order-share-sub { color: rgba(255, 255, 255, 0.9); }
.order-share-card--generic .order-share-thumb {
  background: linear-gradient(145deg, #e8f4ff, #c5ddff);
}
.order-share-card--generic .order-share-linkish { color: #2f6fde; }

.text-image-card {
  background: var(--bg-card-solid);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: var(--font-md);
  line-height: 1.8;
  border: 1px solid var(--border);
  min-width: 200px;
  max-width: 260px;
}

.textimg-card {
  min-width: 220px;
  max-width: 320px;
}
.textimg-card .link-card-icon {
  background: #eef3ff;
  color: #4d6bff;
}
.textimg-card .link-card-title {
  font-weight: 600;
}
.textimg-card .link-card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
