:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #2c2c2a;
  --muted: #5f5e5a;
  --hint: #888780;
  --line: rgba(0, 0, 0, 0.1);
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --self: #1d9e75;
  --self-soft: #e1f5ee;
  --warn-soft: #faeeda;
  --warn: #854f0b;
  --danger: #a32d2d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  overflow: hidden;
}

body { -webkit-text-size-adjust: 100%; }

/* ---------- 登录页语言栏（国旗） ---------- */

.langbar {
  position: absolute;
  top: var(--app-top, 0px); left: 0; right: 0;
  z-index: 30;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: calc(env(safe-area-inset-top) + 5px) 8px 5px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--line);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.langbar::-webkit-scrollbar { display: none; }
.langbar .flag {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: 0;
  padding: 3px 5px;
  border-radius: 8px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--muted);
  cursor: pointer;
}
.langbar .flag img {
  width: 30px; height: 20px;
  display: block;
  border-radius: 3px;
}
.langbar .flag.active { background: var(--accent-soft); color: var(--accent); }
.langbar .flag.active img { outline: 1.5px solid var(--accent); outline-offset: 1px; }
body.langbar-off .langbar { display: none; }

/* 语言栏占掉顶部一行，视图整体下移 */
body:not(.langbar-off) .view {
  top: calc(var(--app-top, 0px) + env(safe-area-inset-top) + 56px);
  height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - 56px);
}

.view {
  position: absolute;
  top: var(--app-top, 0px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100dvh);
  background: var(--bg);
  min-height: 0;
}
#view-login { overflow-y: auto; }
#view-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
#view-chat, #view-history, #view-peer-profile, #view-advisor, #view-admin, #view-account { overflow: hidden; }
.hidden { display: none !important; }

.update-loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
}
.ghb-updating .update-loading { display: flex; }
.update-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: translation-spin 0.8s linear infinite;
}
.update-progress { display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(260px, calc(100vw - 48px)); font-variant-numeric: tabular-nums; }
.update-progress progress { width: 100%; height: 8px; accent-color: var(--accent); }

.theme-download-progress {
  position: fixed;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  z-index: 115;
  width: min(360px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 10px 32px rgb(0 0 0 / 18%);
  color: var(--text);
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.theme-download-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
#theme-download-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
#theme-download-count { flex: none; color: var(--muted); }
.theme-download-progress progress { display: block; width: 100%; height: 8px; accent-color: var(--accent); }
.theme-download-progress.is-error { border-color: color-mix(in srgb, var(--danger) 60%, var(--line)); }
.theme-download-progress.is-error #theme-download-label { color: var(--danger); }

.message-sync {
  position: fixed;
  top: calc(var(--app-top, 0px) + 68px);
  right: max(12px, env(safe-area-inset-right));
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100vw - 24px);
  padding: 8px 11px;
  border: 0.5px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 4px 18px rgb(0 0 0 / 10%);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}
.message-sync-spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: translation-spin 0.8s linear infinite;
}

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

.login-box {
  margin: auto;
  width: min(420px, calc(100% - 40px));
  padding: 28px 22px;
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: 16px;
}
.login-box h1 { font-size: 22px; font-weight: 500; margin: 0 0 6px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.field { display: block; margin-top: 14px; }
.err { color: var(--danger); font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.switch { text-align: center; font-size: 13px; color: var(--muted); margin: 16px 0 0; }
/* 用 button 而不是 a[href="#"]：可点区域更大，也不会有锚点跳转的副作用 */
.switch a,
.switch button.link {
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: 0;
  font: inherit;
  padding: 6px 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

button {
  font: inherit;
  border-radius: 10px;
  border: 0.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
button.primary:disabled { opacity: 0.5; }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
#login-btn { width: 100%; margin-top: 20px; }
#login-cancel { display: block; width: 100%; margin-top: 8px; min-height: 44px; }

/* ---------- 顶栏 ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--line);
  flex: none;
}
.bar h2 { font-size: 16px; font-weight: 500; margin: 0; }
.bar .sub { font-size: 12px; color: var(--muted); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .grow { flex: 1; min-width: 0; }
.bar .center { text-align: center; }
#view-chat > .bar .grow { text-align: start; }
#view-chat > .bar #peer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#peer-state.is-typing { color: var(--accent); font-weight: 600; }
.spacer { width: 48px; flex: none; }
#view-list > .bar > div:first-child { flex: 1; min-width: 0; }
.bar-actions { display: flex; align-items: center; gap: 2px; flex: none; margin-inline-start: auto; }
.bar-actions button { min-height: 44px; min-width: 44px; padding-inline: 9px; white-space: nowrap; }
#bell-btn { position: relative; }
.notification-count {
  position: absolute;
  inset-block-start: 1px;
  inset-inline-end: 0;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid var(--surface);
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.bar .back-button { display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; flex: none; padding: 0; }
.bar .back-button::before { content: ""; display: block; width: 11px; height: 11px; margin-left: 5px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.header-language {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-width: 82px;
  min-height: 44px;
  padding: 7px 8px;
  font-size: 13px;
  white-space: nowrap;
}
.header-language-flag,
.language-menu-flag {
  width: 22px;
  height: 16px;
  flex: none;
  object-fit: cover;
  border: 0.5px solid rgba(0, 0, 0, 0.16);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.header-language-code { font-weight: 700; letter-spacing: 0.04em; }
.header-language-chevron { font-size: 15px; line-height: 1; transform: translateY(-1px); }
.language-menu {
  position: fixed;
  z-index: 35;
  width: min(250px, calc(100vw - 16px));
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.15);
}
.language-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  text-align: start;
  border: 0;
  background: transparent;
}
.language-menu button.active { background: var(--accent-soft); color: var(--accent); }
body:not(.langbar-off) .bar { padding-top: 10px; }

/* ---------- 联系人 ---------- */

.account-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--line);
}
.account-bar label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.account-bar select { flex: 1; width: auto; min-width: 0; padding: 7px 8px; }
.account-bar button { flex: none; min-height: 42px; padding: 7px 10px; white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; min-height: 0; }
#view-list > #partner-list { flex: none; overflow: visible; }
.friend-form { flex: none; padding: 10px 12px 0; background: var(--bg); }
.friend-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.friend-row { display: flex; gap: 8px; }
.friend-row input { flex: 1; min-width: 0; font-size: 16px; }
.friend-row button { flex: none; min-height: 44px; }
.friend-msg { min-height: 18px; margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.relation-section { flex: none; padding: 0 8px; }
.relation-section h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 6px 8px 2px; }
.relation-list { padding: 4px 0; max-height: 125px; }
.relation-list li { margin-bottom: 4px; padding: 5px 8px; }
.relation-list button { min-height: 40px; padding: 7px 9px; }
.status-pill { flex: none; font-size: 12px; color: var(--muted); }
.danger { color: var(--danger) !important; }

.install-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 10px 0;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 0.5px solid rgba(24, 95, 165, 0.35);
  border-radius: 12px;
}
.install-card b { font-weight: 500; display: block; font-size: 14px; color: #0c447c; }
.install-card span { font-size: 12px; color: #185fa5; }
.install-card button { flex: none; padding: 8px 14px; }
.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.list li.partner-item { position: relative; display: block; padding: 0; overflow: hidden; isolation: isolate; }
.partner-main { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px; background: var(--surface); cursor: pointer; touch-action: pan-y; transition: transform 180ms ease; }
.partner-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.partner-item.action-open .partner-main { transform: translateX(-168px); }
.partner-remark-action,
.partner-delete { position: absolute; inset-block: 0; right: 0; display: grid; place-items: center; width: 84px; height: 100%; padding: 0; border: 0; border-radius: 0; background: var(--danger); color: #fff; font-size: 14px; cursor: pointer; }
.partner-remark-action { right: 84px;
  height: 100%; background: var(--accent); }
.partner-remark-action:focus-visible,
.partner-delete:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.dot {
  position: relative;
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 500;
}
.dot > img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.partner-item .partner-avatar { min-height: 40px; padding: 0; border: 0; cursor: pointer; }
.partner-avatar.has-unread, .chat-unread-avatar {
  box-shadow: 0 0 0 2px #dc3545;
  animation: unread-avatar-pulse 1.4s ease-in-out 2;
}
@keyframes unread-avatar-pulse {
  0%, 45%, 100% { transform: scale(1); opacity: 1; }
  22% { transform: scale(1.11); opacity: .68; }
}
@keyframes unread-avatar-flash-reduced {
  0%, 45%, 100% { opacity: 1; }
  22% { opacity: .48; }
}
.partner-language-flag {
  position: absolute; z-index: 2; left: -5px; top: -5px;
  width: 20px; height: 20px; overflow: hidden; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--line);
}
.partner-language-flag img { display: block; width: 100%; height: 100%; object-fit: cover; }
.partner-online-dot {
  position: absolute; z-index: 2; right: -3px; bottom: -3px;
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--surface); background: #a8ce57;
}
.partner-unread-dot {
  position: absolute; z-index: 2; right: -3px; top: -3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #b00020;
}
.chat-peer-avatar { position: relative; width: 38px; height: 38px; flex: none; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: #fff; font-size: 15px; cursor: pointer; overflow: visible; }
.chat-peer-avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.chat-peer-avatar .partner-language-flag { width: 19px; height: 19px; }
.chat-peer-avatar .partner-online-dot { width: 14px; height: 14px; }
.chat-unread-peers { display: flex; align-items: center; gap: 3px; flex: none; }
.chat-unread-peers:empty { display: none; }
.chat-unread-avatar, .chat-unread-more {
  position: relative; display: grid; place-items: center; width: 32px; height: 32px;
  flex: none; padding: 0; border-radius: 50%; cursor: pointer;
}
.chat-unread-avatar { border: 2px solid var(--surface); color: #fff; font-size: 13px; overflow: hidden; }
.chat-unread-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chat-unread-more { border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 22px; line-height: 1; }
.chat-unread-avatar:focus-visible, .chat-unread-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .partner-avatar.has-unread { animation: none; }
  .chat-unread-avatar { animation-name: unread-avatar-flash-reduced; }
}
.list .meta { flex: 1; min-width: 0; }
.list .meta b { font-weight: 500; display: block; }
.list .meta span { font-size: 12px; color: var(--muted); }
.partner-meta { display: grid; align-content: center; gap: 4px; min-width: 0; }
.partner-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partner-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.partner-heading b { min-width: 0; }
.partner-time { flex: none; color: var(--muted); font-size: 11px; text-align: end; white-space: nowrap; }

/* Shared compact timestamps, including the default theme and downloaded themes. */
html body .message-time,
html body .partner-time,
html body .advisor-message-time,
html body .notification-head time,
html body .history-item-meta,
html body #peer-state,
html body #voice-time {
  font-family: "Arial Narrow", "Roboto Condensed", ui-monospace, monospace !important;
  font-size: 9px !important;
  line-height: 11px !important;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}
.list .partner-meta .partner-preview {
  display: block; min-height: 1.3em; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 13px; color: var(--hint);
}
.list .partner-meta .partner-preview.is-unread { color: var(--text); font-weight: 600; }

/* ---------- 聊天记录 ---------- */
.history-controls { flex: none; display: grid; gap: 8px; padding: 10px 12px; background: var(--surface); border-bottom: 0.5px solid var(--line); }
.history-search, .history-time-form { display: flex; align-items: end; gap: 7px; min-width: 0; }
.history-search input { flex: 1; min-width: 0; }
.history-controls button { min-height: 40px; white-space: nowrap; }
.history-time-form label { display: grid; gap: 3px; min-width: 0; flex: 1; color: var(--muted); font-size: 12px; }
.history-time-form input { width: 100%; min-width: 0; font-size: 14px; }
.history-tabs { display: flex; gap: 8px; }
.history-tabs button { flex: 1; }
.history-tabs button[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.history-status { flex: none; min-height: 0; margin: 0; padding: 0 12px; color: var(--muted); font-size: 12px; }
.history-status:not(:empty) { padding-block: 7px; }
.history-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.history-list.history-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); align-content: start; }
.history-photo-grid .history-item { max-width: none; min-width: 0; align-self: stretch; }
.history-photo-grid .history-item-photo { width: 100%; height: 135px; max-width: none; max-height: none; object-fit: cover; }
.history-item { max-width: min(86%, 42rem); padding: 10px 12px; border: 0.5px solid var(--line); border-radius: 12px; background: var(--surface); overflow-wrap: anywhere; }
.history-item.self { align-self: flex-end; background: var(--self-soft); }
.history-item.peer { align-self: flex-start; }
.history-item-meta { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.history-item-text { white-space: pre-wrap; font-size: 14px; }
.history-item-original { margin-top: 6px; color: var(--muted); font-size: 12px; white-space: pre-wrap; }
.history-item-photo { display: block; max-width: min(68vw, 280px); max-height: 240px; border-radius: 8px; object-fit: contain; }
.history-item-photo-link { display: block; min-width: 110px; min-height: 60px; }
.history-photo-grid .video-frame { width: 100%; min-width: 0; }
.history-photo-grid .chat-video { width: 100%; max-height: 180px; }
.history-item-audio { display: block; width: min(66vw, 290px); max-width: 100%; height: 42px; }
.history-item-jump { margin-top: 8px; padding: 4px 8px; font-size: 12px; }
.history-more { flex: none; align-self: center; margin: 6px 0 calc(env(safe-area-inset-bottom) + 8px); }
@media (max-width: 420px) { .history-time-form { flex-wrap: wrap; } .history-time-form button { width: 100%; } }
.hint { text-align: center; color: var(--hint); font-size: 12px; padding: 12px; margin: 0; }

/* ---------- 好友公开资料 ---------- */
.peer-profile-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 12px calc(env(safe-area-inset-bottom) + 28px); }
.peer-profile-card { display: grid; justify-items: center; gap: 8px; width: min(100%, 460px); margin: 0 auto; padding: 24px 18px; border: 0.5px solid var(--line); border-radius: 14px; background: var(--surface); }
.peer-profile-card .profile-avatar-preview { width: 108px; height: 108px; font-size: 36px; }
.peer-profile-card h3 { margin: 5px 0 0; overflow-wrap: anywhere; text-align: center; }
.peer-profile-card .profile-login-name { margin: 0; }
.peer-profile-facts { width: 100%; margin: 14px 0 0; }
.peer-profile-facts > div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 2px; border-top: 0.5px solid var(--line); }
.peer-profile-facts dt { color: var(--muted); }
.peer-profile-facts dd { margin: 0; text-align: end; overflow-wrap: anywhere; }
.peer-profile-language-value { display: inline-flex; align-items: center; justify-content: flex-end; gap: 7px; }
.peer-profile-language-flag { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.peer-profile-card > button { width: 100%; min-height: 44px; margin-top: 8px; }
.peer-profile-remark-form { display: grid; gap: 7px; width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--bg); }
.peer-profile-remark-form > label { color: var(--muted); font-size: 13px; }
.peer-profile-remark-actions { display: flex; justify-content: flex-end; gap: 8px; }
.peer-profile-remark-actions button { min-height: 42px; }
.peer-profile-remark-actions .primary { width: auto; margin-top: 0; }

/* ---------- 账户资料 ---------- */
#view-list > .bar h2 { overflow-wrap: anywhere; line-height: 1.2; }
.account-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 12px calc(env(safe-area-inset-bottom) + 28px); }
.profile-card { display: grid; gap: 8px; width: min(100%, 460px); margin: 0 auto; padding: 18px; border-radius: 14px; border: 0.5px solid var(--line); background: var(--surface); }
.profile-card > label { margin-top: 7px; font-size: 13px; color: var(--muted); }
.profile-card > button.primary { min-height: 46px; margin-top: 10px; }
.profile-time-zone-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.profile-time-zone-row select { flex: 1; min-width: 0; width: 100%; }
.profile-time-zone-row button { flex: none; min-height: 42px; padding-inline: 10px; white-space: nowrap; }
.profile-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.profile-avatar-preview { position: relative; display: grid; place-items: center; width: 88px; height: 88px; flex: none; overflow: hidden; border-radius: 50%; color: #fff; font-size: 30px; background: var(--accent); }
.profile-avatar-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-actions { display: grid; gap: 4px; min-width: 0; }
.profile-avatar-actions strong { overflow-wrap: anywhere; }
.profile-login-name { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.profile-avatar-actions label { display: grid; place-items: center; min-height: 42px; padding: 7px 10px; border-radius: 10px; color: var(--accent); cursor: pointer; }
.profile-avatar-actions button { min-height: 42px; }
.profile-crop { display: grid; justify-items: center; gap: 8px; padding: 10px; border-radius: 12px; background: var(--bg); }
.profile-crop canvas { width: min(220px, 100%); height: auto; aspect-ratio: 1; border-radius: 50%; touch-action: none; cursor: grab; }
.profile-crop canvas:active { cursor: grabbing; }
.profile-crop p { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.profile-crop label { justify-self: stretch; font-size: 13px; color: var(--muted); }
.profile-crop input { padding: 5px 0; }
.profile-crop-actions { display: flex; justify-content: flex-end; gap: 5px; width: 100%; }
.profile-crop-actions button { min-height: 42px; }

/* ---------- 管理员模型设置 ---------- */

.admin-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px calc(env(safe-area-inset-bottom) + 24px); }
.admin-scroll > h3, .admin-form h3 { font-size: 17px; font-weight: 600; margin: 4px 0 6px; }
.admin-scroll > .hint { text-align: left; padding: 0 0 12px; }
.model-list { display: grid; gap: 9px; }
.model-card { background: var(--surface); border: 0.5px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.model-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.model-head b { overflow-wrap: anywhere; }
.model-detail { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin-top: 4px; }
.model-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.model-actions button { min-height: 40px; }
.admin-form { display: grid; gap: 7px; margin-top: 18px; padding: 14px; background: var(--surface); border: 0.5px solid var(--line); border-radius: 12px; }
.admin-form label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.admin-form input { min-width: 0; }
.admin-form button { min-height: 44px; margin-top: 10px; }
.ip-allowlist-section { margin-top: 22px; }
.ip-allowlist-section h3 { font-size: 17px; margin: 0 0 6px; }
.ip-allowlist-section > .hint { text-align: left; padding: 0 0 10px; }
.admin-search-row { display: flex; gap: 7px; margin-bottom: 10px; }
.admin-search-row input { flex: 1; min-width: 0; }
.admin-table-wrap { width: 100%; overflow-x: auto; border: 0.5px solid var(--line); border-radius: 10px; background: var(--surface); }
.admin-data-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.admin-data-table th, .admin-data-table td { padding: 9px 10px; border-bottom: 0.5px solid var(--line); text-align: left; vertical-align: top; font-size: 12px; overflow-wrap: anywhere; }
.admin-data-table th { color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
.admin-data-table tr:last-child td { border-bottom: 0; }
.admin-data-table button { min-height: 36px; white-space: nowrap; }
.admin-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.admin-pager span { color: var(--muted); font-size: 12px; text-align: center; }
.admin-pager button { min-height: 40px; }
.audit-section { margin-top: 22px; }
.audit-section h3 { font-size: 17px; margin: 0 0 6px; }
.audit-section .hint { text-align: left; padding: 0 0 10px; }
.audit-section label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.audit-section select { margin-bottom: 10px; }
.audit-list { display: grid; gap: 8px; }
.audit-card { display: grid; gap: 4px; min-width: 0; padding: 11px; background: var(--surface); border: 0.5px solid var(--line); border-radius: 10px; }
.audit-card b { font-size: 14px; font-weight: 600; }
.audit-card .audit-last-message { color: var(--accent); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.audit-card span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- 消息 ---------- */

.msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}
.message-pane { position: relative; display: flex; flex: 1; min-height: 0; }
.message-pane .msgs { width: 100%; }

.row { display: flex; flex-direction: column; max-width: min(82%, 36rem); min-width: 0; }
.row.self { align-self: flex-end; align-items: flex-end; }
.row.peer { align-self: flex-start; align-items: flex-start; }

.bubble {
  position: relative;
  padding: 6px 12px 8px;
  border-radius: 14px;
  background: var(--surface);
  border: 0.5px solid var(--line);
  word-break: break-word;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  touch-action: pan-y;
}
.bubble.has-dated-time { min-width: 138px; }
.bubble.has-peer-avatar.has-dated-time { min-width: 152px; }
.message-time {
  position: absolute;
  z-index: 2;
  top: -1px;
  right: 9px;
  transform: translateY(-100%);
  padding: 0 3px;
  border-radius: 3px;
  background: transparent;
  color: var(--hint);
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 9px;
  line-height: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row.self .message-time { background: transparent; }
.row.peer .bubble.has-peer-avatar { position: relative; padding-left: 34px; }
.message-peer-avatar-button {
  position: absolute;
  left: -12px;
  top: -10px;
  z-index: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
  cursor: pointer;
}
.message-peer-avatar { display: block; width: 100%; height: 100%; object-fit: cover; }
.row.self .bubble { position: relative; background: var(--self-soft); border-color: rgba(29, 158, 117, 0.3); }
.outbox-text { font-size: 15px; }
.outbox-status { margin-top: 1px; padding: 2px 4px; color: var(--hint); font-size: 11px; line-height: 1.35; }
button.outbox-status { min-height: 32px; padding: 5px 6px; border: 0; background: transparent; font-family: inherit; cursor: pointer; }
button.outbox-failed { color: var(--danger); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
button.outbox-failed:focus-visible { outline: 2px solid var(--danger); border-radius: 3px; }
.row .bubble.recalled-bubble { background: var(--surface); border-style: dashed; color: var(--hint); }
.recalled-line { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.recalled-text { color: var(--hint); font-size: 13px; }
.recalled-edit { min-height: 28px; padding: 2px 6px; border: 0; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; }
.recalled-edit:disabled { opacity: 0.5; cursor: default; }

.bubble .translated { font-size: 15px; }
.quote-reference {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 20rem;
  width: 100%;
  margin-bottom: 7px;
  padding: 5px 8px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.quote-reference:hover { background: var(--self-soft); }
.quote-reference:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quote-reference b, .quote-reference span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-reference b { color: var(--accent); }
.quote-reference span { color: var(--muted); }
.quote-target-flash .bubble { outline: 2px solid var(--accent); outline-offset: 3px; }
.jump-latest {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  font-size: 22px;
  line-height: 1;
}
.bubble .pending { color: var(--hint); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.bubble .translation-failed { margin-top: 6px; color: var(--hint); font-size: 12px; }
.bubble .translation-retry {
  display: block;
  min-height: 28px;
  margin: 6px 0 0;
  padding: 3px 10px;
  border: 1px solid currentColor;
  border-radius: 7px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.bubble .translation-retry:disabled { cursor: default; opacity: 0.55; }
.translation-spinner {
  display: inline-block;
  flex: none;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: translation-spin 0.8s linear infinite;
}
@keyframes translation-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .translation-spinner, .update-spinner, .message-sync-spinner { animation-duration: 2s; }
}
.bubble .origin {
  display: block;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 0.5px dashed var(--line);
  font-size: 13px;
  color: var(--muted);
}
.bubble.failed-translation .origin { margin-top: 0; padding-top: 0; border-top: 0; font-size: 14px; color: inherit; }
.bubble.collapsed-origin .origin { display: none; }
.image-frame { min-width: 110px; max-width: min(72vw, 320px); }
.cli-image-toggle { display: none; }
.image-upload-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; color: var(--hint); font-size: 11px; }
.image-upload-badge::before { content: ""; width: 11px; height: 11px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: translation-spin 0.8s linear infinite; }
.image-status { display: block; color: var(--hint); font-size: 13px; padding: 20px 8px; }
.image-original { display: block; color: var(--accent); font-size: 13px; }
.chat-image { display: block; max-width: 100%; max-height: min(52vh, 420px); width: auto; height: auto; border-radius: 9px; object-fit: contain; }
.video-frame { width: min(72vw, 320px); max-width: 100%; min-width: 150px; }
.video-play { display: grid; place-items: center; width: 100%; min-height: 110px; padding: 12px; border: 0; border-radius: 9px; background: #1b2630; color: #fff; font: inherit; cursor: pointer; }
.video-play::before { content: "▶"; display: block; font-size: 28px; }
.chat-video { display: block; width: 100%; max-height: min(52vh, 420px); border-radius: 9px; background: #111; touch-action: auto; }
.video-download { display: inline-block; margin-top: 6px; color: var(--accent); font-size: 12px; }
.video-error { display: block; margin-top: 5px; color: var(--warn); font-size: 12px; }
.sticker-frame { width: 72px; height: 72px; min-width: 72px; max-width: 72px; overflow: hidden; -webkit-touch-callout: none; user-select: none; }
.sticker-frame .image-content { width: 100%; height: 100%; }
.sticker-frame .image-status { box-sizing: border-box; display: grid; place-items: center; width: 100%; height: 100%; padding: 4px; text-align: center; }
.sticker-original { display: grid; place-items: center; width: 100%; height: 100%; }
.sticker-image { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
.sticker-message-menu { position: fixed; z-index: 38; display: grid; gap: 2px; min-width: 152px; padding: 5px; border: 0.5px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16); }
.sticker-message-menu button { min-height: 42px; padding: 8px 12px; border: 0; background: transparent; color: var(--text); text-align: start; }
.sticker-message-menu button:hover, .sticker-message-menu button:focus-visible { background: var(--accent-soft); color: var(--accent); }
.audio-message { display: block; width: min(66vw, 290px); max-width: 100%; height: 42px; }
.file-card { box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: min(72vw, 330px); max-width: 100%; min-width: 190px; padding: 9px; border: 1px solid color-mix(in srgb, currentColor 16%, transparent); border-radius: 10px; color: inherit; text-decoration: none; }
.file-card:hover, .file-card:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.file-card-icon { display: grid; place-items: center; flex: none; width: 45px; height: 52px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.file-card-info { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.file-card-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-card-size { min-height: 1em; color: var(--muted); font-size: 11px; }
.file-card-action { color: var(--accent); font-size: 12px; }

.note {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
}
.note b { font-weight: 500; }

.expl {
  margin-top: 8px;
  padding: 10px 11px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #0c447c;
  font-size: 13px;
  white-space: pre-wrap;
}
.expl-error { margin-top: 8px; color: var(--danger); font-size: 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 0; }
.actions button {
  background: transparent;
  border: none;
  color: var(--hint);
  font-size: 12px;
  padding: 2px 7px;
  min-height: 28px;
}
.actions button:disabled { opacity: 0.45; }
.read-receipt {
  position: absolute;
  left: -43px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 31px;
  border: 0;
  color: var(--hint);
  background: transparent;
}
.receipt-envelope {
  display: block;
  width: 28px;
  height: 28px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: center;
}
.read-receipt.is-unread .receipt-envelope { transform: rotate(-12deg); }
.read-receipt.is-read {
  display: flex;
  height: 35px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--self);
}
.read-receipt.is-read .receipt-envelope {
  flex: none;
  width: 30px;
  height: 24px;
  stroke-width: 1.25;
  transform: none;
}
.receipt-envelope-letter,
.receipt-envelope-pocket { fill: var(--bg); }
.read-receipt-label {
  position: static;
  flex: none;
  transform: none;
  padding: 0;
  background: transparent;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/* ---------- 输入区 ---------- */

.composer {
  flex: none;
  background: var(--surface);
  border-top: 0.5px solid var(--line);
  padding: 5px 10px clamp(3px, env(safe-area-inset-bottom), 12px);
}
.composer-menu {
  margin-bottom: 8px;
  padding: 9px;
  border: 0.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.quote-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  background: var(--accent-soft);
}
.quote-preview-content { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; font-size: 12px; }
.quote-preview-content b { color: var(--accent); }
.quote-preview-content span { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.quote-cancel { flex: none; border: 0; background: transparent; color: var(--muted); font-size: 21px; width: 32px; height: 32px; }
.langrow {
  display: flex;
  align-items: center;
  gap: 6px;
}
.langrow .mini { width: auto; min-width: 0; flex: 1; padding: 7px 8px; font-size: 16px; border-radius: 8px; }
.mini-btn { padding: 7px 9px; min-height: 40px; font-size: 16px; }
.paste-image-button { width: 100%; min-height: 40px; margin-top: 8px; }
.state { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--hint); text-align: right; }

.inputrow { display: flex; gap: 7px; align-items: flex-end; }
.inputrow.file-drag-over #input { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
#input { flex: 1; min-width: 0; resize: none; max-height: 120px; border-radius: 12px; font-size: 16px; }
.voice-draft { box-sizing: border-box; display: flex; align-items: center; flex: 1; gap: 7px; min-width: 0; height: 44px; padding: 3px 6px 3px 10px; border: 1px solid var(--accent); border-radius: 12px; background: var(--surface); }
.voice-live-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #e04e4e; animation: voice-pulse 1.1s ease-in-out infinite; }
@keyframes voice-pulse { 50% { opacity: .3; } }
#voice-wave { display: block; flex: 1; width: 100%; min-width: 0; height: 36px; }
#voice-time { flex: none; min-width: 2.5em; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#voice-cancel { flex: none; width: 32px; height: 32px; padding: 0; border: 0; color: var(--muted); font-size: 25px; line-height: 1; }
.voice-toggle[aria-pressed="true"] { color: #d33; background: color-mix(in srgb, #d33 12%, transparent); }
.composer-toggle, .send { flex: none; display: grid; place-items: center; width: 42px; height: 44px; padding: 0; border-radius: 12px; }
.composer-toggle { color: var(--accent); font-size: 27px; font-weight: 300; line-height: 1; }
.send svg { width: 21px; height: 21px; }
.toolrow { display: flex; align-items: center; gap: 4px; min-height: 40px; margin-top: 1px; }
.toolrow > button { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border-radius: 10px; color: var(--muted); }
.toolrow > button svg { width: 21px; height: 21px; }
.toolrow > button:hover, .toolrow > button[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
.toolrow > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolrow > button:disabled { opacity: 0.45; }
.advisor-header { display: flex; align-items: center; gap: 10px; min-width: 0; }
.advisor-header-copy { min-width: 0; }
.advisor-header-copy h2, .advisor-header-copy p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.advisor-thread { background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 78%, #eef8fc), var(--bg)); }
.advisor-thread .row.peer { max-width: min(94%, 42rem); }
.advisor-thread .row.self { max-width: min(82%, 36rem); margin-block: 2px 8px; }
.advisor-thread .row.self .advisor-bubble { background: color-mix(in srgb, var(--accent-soft) 78%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); }
.advisor-pending-group { display: contents; }
.advisor-agent-row { flex-direction: row; align-items: flex-end; gap: 7px; margin-block-end: 10px; }
.advisor-agent-row .advisor-bubble { min-width: 0; }
.advisor-bubble { font-size: 15px; line-height: 1.55; }
.advisor-answer-bubble, .advisor-pending-bubble { flex: 1; max-width: min(calc(100% - 41px), 38rem); white-space: normal; box-shadow: 0 4px 14px rgb(28 69 91 / 7%); }
.advisor-question-bubble { white-space: pre-wrap; }
.advisor-answer-label { display: block; margin-block-end: 4px; color: var(--accent); font-size: 11px; font-weight: 650; }
.advisor-answer-label::before { content: "✦"; margin-inline-end: 5px; color: #e9935c; }
.advisor-answer-text { display: block; white-space: pre-wrap; }
.advisor-message-time { position: absolute; inset-block-start: -7px; inset-inline-end: 9px; padding-inline: 3px; border-radius: 3px; background: inherit; color: var(--hint); font-size: 10px; line-height: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.advisor-bot { position: relative; display: grid; place-items: center; width: 34px; height: 32px; flex: none; border: 2px solid #5f8ca6; border-radius: 13px 13px 15px 15px; background: linear-gradient(145deg,#fff,#ccecf8); box-shadow: 0 5px 12px rgb(71 118 143 / 16%); transform-origin: 50% 100%; }
.advisor-bot::before { content: ""; position: absolute; inset-block-start: -8px; inset-inline-start: calc(50% - 1px); width: 2px; height: 7px; background: #5f8ca6; }
.advisor-bot::after { content: ""; position: absolute; inset-block-start: -12px; inset-inline-start: calc(50% - 4px); width: 8px; height: 8px; border-radius: 50%; background: #ffc573; box-shadow: 0 0 0 3px #fff3dd; }
.advisor-bot-eyes { display: flex; gap: 7px; margin-block-start: -4px; }
.advisor-bot-eyes i { width: 4px; height: 6px; border-radius: 4px; background: #315c74; transform-origin: center; }
.advisor-bot-mouth { position: absolute; inset-inline-start: calc(50% - 4px); inset-block-start: 21px; width: 8px; height: 4px; border-block-end: 2px solid #d47f89; border-radius: 50%; }
.advisor-bot-cheek { position: absolute; inset-block-start: 18px; width: 4px; height: 2px; border-radius: 999px; background: #f6b0b4; opacity: .75; }
.advisor-bot-cheek.left { inset-inline-start: 5px; }.advisor-bot-cheek.right { inset-inline-end: 5px; }
.advisor-bot.is-thinking { animation: advisor-think 1.1s ease-in-out infinite; }
.advisor-bot.is-sad .advisor-bot-mouth { inset-block-start: 24px; border-block-start: 2px solid #d47f89; border-block-end: 0; }
.advisor-bot-header { width: 38px; height: 36px; border-radius: 14px 14px 16px 16px; }
.advisor-bot-header, .advisor-bot-large { animation: advisor-breathe 3.6s ease-in-out infinite; }
.advisor-bot-header .advisor-bot-eyes i, .advisor-bot-large .advisor-bot-eyes i { animation: advisor-blink 4.4s infinite; }
.advisor-bot-header .advisor-bot-mouth { inset-block-start: 24px; }
.advisor-bot-header .advisor-bot-cheek { inset-block-start: 21px; }

.advisor-empty { display: grid; justify-items: center; align-content: center; gap: 14px; width: min(100%, 34rem); min-height: 100%; margin: auto; padding: 24px 12px; }
.advisor-empty .advisor-hint { max-width: 30rem; margin: 4px 0; color: var(--muted); font-size: 14px; line-height: 1.65; text-align: center; }
.advisor-bot-large { width: 82px; height: 74px; border-width: 3px; border-radius: 28px 28px 32px 32px; box-shadow: 0 15px 28px rgb(71 118 143 / 18%); }
.advisor-bot-large::before { inset-block-start: -15px; width: 3px; height: 13px; }.advisor-bot-large::after { inset-block-start: -22px; inset-inline-start: calc(50% - 7px); width: 14px; height: 14px; box-shadow: 0 0 0 5px #fff3dd; }
.advisor-bot-large .advisor-bot-eyes { gap: 17px; margin-block-start: -9px; }.advisor-bot-large .advisor-bot-eyes i { width: 8px; height: 12px; }
.advisor-bot-large .advisor-bot-mouth { inset-inline-start: calc(50% - 9px); inset-block-start: 51px; width: 18px; height: 7px; border-block-end-width: 3px; }
.advisor-bot-large .advisor-bot-cheek { inset-block-start: 44px; width: 9px; height: 4px; }.advisor-bot-large .advisor-bot-cheek.left { inset-inline-start: 13px; }.advisor-bot-large .advisor-bot-cheek.right { inset-inline-end: 13px; }
.advisor-quick-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; width: 100%; }
.advisor-quick-prompt { min-height: 40px; max-width: 100%; padding: 7px 11px; border-color: var(--line) !important; border-radius: 999px; background: color-mix(in srgb, var(--surface) 92%, transparent) !important; font-size: 12px; overflow-wrap: anywhere; }

.advisor-evidence { margin-block-start: 9px; padding-block-start: 7px; border-block-start: 0.5px dashed var(--line); }
.advisor-evidence summary { min-height: 30px; padding-block: 5px; color: var(--accent); font-size: 12px; cursor: pointer; list-style: none; }
.advisor-evidence summary::-webkit-details-marker { display: none; }
.advisor-evidence summary::after { content: "▾"; margin-inline-start: 5px; font-size: 10px; }
.advisor-evidence[open] summary::after { content: "▴"; }
.advisor-evidence-body { display: grid; gap: 7px; padding: 8px; border-radius: 10px; background: var(--bg); }
.advisor-evidence-title { color: var(--muted); font-size: 11px; font-weight: 600; }
.advisor-evidence-item { display: grid; gap: 2px; padding-inline-start: 8px; border-inline-start: 2px solid color-mix(in srgb, var(--accent) 45%, var(--line)); }
.advisor-evidence-meta { color: var(--hint); font-size: 10px; font-variant-numeric: tabular-nums; }
.advisor-evidence-text { color: var(--muted); font-size: 12px; white-space: pre-wrap; }

.advisor-pending-bubble { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.advisor-thinking-dots { display: inline-flex; gap: 4px; flex: none; }
.advisor-thinking-dot { width: 5px; height: 5px; border-radius: 50%; background: #6f98ad; animation: advisor-dot 1s ease-in-out infinite; }
.advisor-thinking-dot:nth-child(2) { animation-delay: .15s; }.advisor-thinking-dot:nth-child(3) { animation-delay: .3s; }
.advisor-failed .advisor-pending-bubble { flex-wrap: wrap; border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.advisor-failed-text { flex: 1; min-width: 12rem; color: var(--danger); }
.advisor-retry { min-width: 68px; min-height: 40px; margin-inline-start: auto; color: var(--danger) !important; }

.advisor-rules { flex: none; border-bottom: 0.5px solid #eadfce; background: color-mix(in srgb, var(--surface) 88%, #fff2df); padding: 0 12px; }
.advisor-rules summary { display: flex; align-items: center; min-height: 40px; color: #8a5c3c; font-size: 13px; cursor: pointer; }
.advisor-rule-list { display: grid; gap: 7px; max-height: min(28dvh, 240px); overflow-y: auto; padding: 0 0 9px; }
.advisor-rule-empty { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.advisor-rule-item { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 9px; border-radius: 9px; background: var(--bg); }
.advisor-rule-body { display: grid; gap: 3px; flex: 1; min-width: 0; }
.advisor-rule-meta { color: var(--muted); font-size: 11px; }
.advisor-rule-text { font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.advisor-rule-delete { flex: none; min-height: 36px; font-size: 12px; }
.advisor-composer { padding-top: 8px; }
.advisor-composer #advisor-input { flex: 1; min-width: 0; resize: none; max-height: 120px; border-radius: 12px; font-size: 16px; }
.advisor-composer #advisor-more { width: 100%; min-height: 36px; margin-bottom: 6px; }
.advisor-status { min-height: 0; margin: 0 2px 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.advisor-status:empty { display: none; }
@keyframes advisor-breathe { 50% { transform: translateY(-1px) scale(1.025); } }
@keyframes advisor-blink { 0%,46%,50%,100% { transform: scaleY(1); } 48% { transform: scaleY(.08); } }
@keyframes advisor-think { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(4deg); } }
@keyframes advisor-dot { 0%,100% { transform: translateY(0); opacity: .3; } 50% { transform: translateY(-4px); opacity: 1; } }
@media (max-width: 420px) {
  .advisor-thread { padding-inline: 9px; }
  .advisor-thread .row.peer { max-width: 98%; }
  .advisor-thread .row.self { max-width: 86%; }
  .advisor-agent-row { gap: 6px; }
  .advisor-answer-bubble, .advisor-pending-bubble { max-width: calc(100% - 40px); }
  .advisor-header { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .advisor-bot, .advisor-bot-eyes i, .advisor-thinking-dot { animation: none !important; }
}
.image-storage { margin: 8px 2px 0; color: var(--hint); font-size: 11px; line-height: 1.3; }
.image-storage:empty, .image-warning:empty { display: none; }
.image-warning { margin: 4px 2px 0; color: var(--warn); font-size: 12px; line-height: 1.35; }
.emoji-picker {
  display: flex;
  flex-direction: column;
  width: min(100%, 440px);
  max-height: min(80dvh, 340px);
  overflow: hidden;
  margin-bottom: 7px;
  border: 0.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.emoji-tabs { display: flex; align-items: center; gap: 3px; flex: none; padding: 3px 5px; border-bottom: 0.5px solid var(--line); }
.emoji-tabs button { border: 0; background: transparent; color: var(--muted); min-height: 32px; padding: 3px 10px; font-size: 13px; }
.emoji-tabs [role="tab"][aria-selected="true"] { color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px var(--accent); }
.emoji-tabs #sticker-manage { margin-left: auto; color: var(--accent); }
.emoji-default-view { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.emoji-categories { display: flex; flex: none; gap: 2px; padding: 3px 5px; overflow-x: auto; scrollbar-width: none; border-bottom: 0.5px solid var(--line); }
.emoji-categories::-webkit-scrollbar { display: none; }
.emoji-categories button { display: grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; font-size: 20px; }
.emoji-categories button[aria-pressed="true"] { background: var(--accent-soft); }
.emoji-categories button:focus-visible, .emoji-pages button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.emoji-swipe-viewport { position: relative; flex: none; height: 190px; overflow: hidden; touch-action: pan-y; --emoji-drag-x: 0px; }
.emoji-pages { display: flex; align-items: center; justify-content: center; flex: none; gap: 12px; min-height: 34px; border-top: 0.5px solid var(--line); }
.emoji-pages button { width: 40px; height: 32px; padding: 0; border: 0; color: var(--accent); font-size: 27px; line-height: 1; }
.emoji-pages button:disabled { color: var(--hint); opacity: .45; }
.emoji-pages span { min-width: 4em; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.emoji-grid, .sticker-grid { display: grid; gap: 2px; min-height: 0; overflow-y: auto; padding: 4px; }
.emoji-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (min-width: 600px) { .emoji-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.emoji-grid { position: absolute; inset: 0; width: 100%; height: 190px; box-sizing: border-box; grid-auto-rows: 44px; overflow: hidden; touch-action: pan-y; will-change: transform; }
#emoji-prev-panel { transform: translate3d(calc(var(--emoji-drag-x) - 100%), 0, 0); }
#emoji-default-panel { transform: translate3d(var(--emoji-drag-x), 0, 0); }
#emoji-next-panel { transform: translate3d(calc(var(--emoji-drag-x) + 100%), 0, 0); }
.emoji-swipe-viewport.is-settling .emoji-grid { transition: transform 220ms ease-out; }
.emoji-ghost { pointer-events: none; }
.sticker-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.emoji-grid button, .sticker-grid button {
  min-width: 0;
  min-height: 44px;
  padding: 3px;
  border: 0;
  background: transparent;
}
.emoji-grid button {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 24px;
  line-height: 1;
}
.sticker-panel { display: flex; flex-direction: column; min-height: 0; }
.sticker-grid button { position: relative; height: 54px; border-radius: 8px; }
.sticker-grid button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sticker-grid img { width: 100%; height: 100%; object-fit: contain; }
.sticker-grid .sticker-add { border: 1px dashed var(--line); color: var(--accent); font-size: 27px; line-height: 1; }
.sticker-grid .sticker-remove::after { content: "×"; position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: var(--danger); color: white; font: 16px/1 sans-serif; }
.sticker-status { margin: 0; padding: 3px 8px 5px; color: var(--warn); font-size: 12px; }
.sticker-status:empty { display: none; }

/* ---------- 说明弹层 ---------- */

.sheet {
  position: absolute;
  top: var(--app-top, 0px);
  left: 0;
  right: 0;
  height: var(--app-height, 100dvh);
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}
.sheet-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  max-width: 380px;
}
.sheet-box h3 { margin: 0 0 10px; font-size: 16px; font-weight: 500; }
.sheet-box p, .sheet-box li { font-size: 14px; color: var(--text); }
.sheet-box ol { padding-inline-start: 20px; }
.sheet-box .primary { width: 100%; margin-top: 14px; }
.remark-editor-box { display: grid; gap: 8px; width: min(380px, 100%); }
.remark-editor-box > label { color: var(--muted); font-size: 13px; }
.remark-editor-box input { width: 100%; }
.remark-editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.remark-editor-actions button { min-height: 42px; }
.remark-editor-actions .primary { width: auto; margin-top: 0; }

.paste-image-box { width: min(560px, 100%); max-width: none; max-height: min(86dvh, 720px); display: flex; flex-direction: column; min-height: 0; }
.paste-image-frame { min-height: 0; display: grid; place-items: center; overflow: hidden; background: var(--accent-soft); border-radius: 10px; }
.paste-image-frame img { display: block; max-width: 100%; max-height: min(58dvh, 560px); object-fit: contain; }
.paste-file-preview { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 18px; border-radius: 10px; background: var(--accent-soft); }
.paste-file-icon { display: grid; place-items: center; flex: none; width: 58px; height: 68px; padding: 4px; border-radius: 8px; background: var(--surface); color: var(--accent); font-size: 11px; font-weight: 700; overflow: hidden; }
.paste-file-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.paste-file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paste-file-copy span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.paste-image-box #paste-image-error { margin: 8px 0 0; color: var(--warn); }
.paste-image-box #paste-image-error:empty { display: none; }
.paste-image-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.paste-image-actions button { min-width: 100px; min-height: 44px; }
.paste-image-actions .primary { width: auto; margin-top: 0; }

.image-viewer { background: rgba(0, 0, 0, 0.93); z-index: 45; }
.image-viewer-box { position: relative; width: min(100%, 1100px); height: 100%; display: grid; place-items: center; min-height: 0; overflow: hidden; }
.image-viewer-close { position: absolute; top: 0; right: 0; z-index: 2; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: white; font-size: 30px; line-height: 1; cursor: pointer; }
.image-viewer-stage { width: 100%; height: 100%; display: grid; place-items: center; overflow: hidden; touch-action: none; overscroll-behavior: contain; user-select: none; -webkit-user-select: none; }
.image-viewer-photo, .image-viewer-video { grid-area: 1 / 1; display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; transform: translate3d(0, 0, 0) scale(1); transform-origin: center; will-change: transform; }
.image-viewer-video { background: black; }
.image-viewer-nav { position: absolute; top: 50%; z-index: 3; width: 44px; height: 56px; transform: translateY(-50%); border: 0; border-radius: 999px; background: rgba(0, 0, 0, 0.42); color: white; font-size: 38px; line-height: 1; cursor: pointer; }
.image-viewer-nav:disabled { opacity: 0.2; cursor: default; }
.image-viewer-prev { left: 8px; }
.image-viewer-next { right: 8px; }
.image-viewer-count { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); z-index: 2; transform: translateX(-50%); padding: 4px 9px; border-radius: 999px; background: rgba(0, 0, 0, 0.56); color: white; font-size: 12px; }
.image-viewer-toolbar { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 3; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; }
.image-viewer-toolbar button { min-width: 44px; height: 42px; padding: 0 12px; border: 0; background: rgba(20, 20, 20, 0.78); color: white; cursor: pointer; }
.image-viewer-toolbar button:disabled { opacity: 0.38; cursor: default; }
.image-viewer-original { border-radius: 999px !important; white-space: nowrap; }
.image-viewer-zoom { display: flex; overflow: hidden; border-radius: 999px; background: rgba(20, 20, 20, 0.78); }
.image-viewer-zoom button { border-radius: 0; background: transparent; font-size: 20px; }
.image-viewer-zoom #image-viewer-zoom-reset { min-width: 58px; padding: 0 8px; border-right: 1px solid rgba(255, 255, 255, 0.16); border-left: 1px solid rgba(255, 255, 255, 0.16); font-size: 12px; }
.image-viewer-progress { position: absolute; left: 50%; bottom: max(70px, calc(env(safe-area-inset-bottom) + 58px)); z-index: 4; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 20px); padding: 8px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.72); color: white; font-size: 12px; white-space: nowrap; }
.image-viewer-ring { --download-progress: 0%; position: relative; display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: conic-gradient(var(--accent) var(--download-progress), rgba(255, 255, 255, 0.3) 0); font-size: 10px; }
.image-viewer-ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #1b1b1b; }
.image-viewer-ring.is-indeterminate { background: none; border: 3px solid rgba(255, 255, 255, 0.3); border-right-color: var(--accent); animation: translation-spin 0.8s linear infinite; }
.image-viewer-ring.is-indeterminate::before { display: none; }
.image-viewer-ring span { position: relative; z-index: 1; }
#image-viewer-retry { color: white; background: transparent; border: 1px solid currentColor; border-radius: 6px; padding: 5px 8px; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .image-upload-badge::before, .image-viewer-ring.is-indeterminate { animation-duration: 2s; } }
.file-viewer { z-index: 46; padding: 0; background: var(--surface); }
.file-viewer-box { display: flex; flex-direction: column; width: 100%; max-width: 100%; height: 100%; min-width: 0; min-height: 0; background: var(--surface); }
.file-viewer-bar { display: flex; align-items: center; gap: 8px; flex: none; min-height: 52px; padding: env(safe-area-inset-top) 10px 0; border-bottom: 0.5px solid var(--line); background: var(--surface); }
.file-viewer-bar strong { flex: 1; min-width: 0; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.file-viewer-close { flex: none; width: 42px; height: 42px; padding: 0; color: var(--accent); font-size: 24px; }
.file-viewer-save { flex: none; min-width: 42px; padding: 9px 8px; color: var(--accent); font-size: 12px; text-align: center; text-decoration: none; }
.file-viewer-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
.pdf-viewer-scroller { position: relative; flex: 1; width: 100%; max-width: 100%; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; background: #777; }
.pdf-viewer-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; box-sizing: content-box; min-width: 100%; min-height: 100%; padding: 8px 0 40px; }
.pdf-page { flex: none; overflow: hidden; background: #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.32); }
.pdf-page-canvas { display: block; }
.pdf-page-error { background: repeating-linear-gradient(135deg, #fff, #fff 10px, #f2f2f2 10px, #f2f2f2 20px); }
.pdf-viewer-status { position: sticky; z-index: 2; top: 12px; display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 24px); margin: 12px auto -48px; padding: 8px 12px; border-radius: 999px; background: rgba(20, 20, 20, 0.82); color: #fff; font-size: 13px; }
.pdf-viewer-status[hidden] { display: none; }
.pdf-viewer-status button { min-height: 32px; padding: 5px 9px; border-color: currentColor; color: inherit; }

.notification-box {
  width: min(440px, 100%);
  max-width: none;
  max-height: min(78dvh, 650px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
#notification-center { grid-template-columns: minmax(0, 1fr); }
.notification-title-row,
.notification-setting,
.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.notification-title-row { margin-bottom: 14px; }
.notification-title-row h3 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.notification-title-row button { flex: none; min-height: 40px; }
.notification-setting {
  padding: 12px;
  border-radius: 12px;
  background: var(--accent-soft);
}
.notification-setting > div { min-width: 0; overflow-wrap: anywhere; }
.notification-setting b { font-size: 14px; }
.notification-setting p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.notification-setting button { flex: none; max-width: 45%; min-height: 42px; white-space: normal; overflow-wrap: anywhere; }
.notification-setting button:disabled { opacity: 0.5; }
.notification-box h4 { margin: 18px 0 4px; font-size: 14px; font-weight: 500; }
.notification-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; min-width: 0; }
.notification-list li { border-top: 0.5px solid var(--line); }
.notification-list .notification-empty { padding: 18px 4px; color: var(--muted); font-size: 14px; }
.notification-item { display: block; width: 100%; padding: 12px 4px; border: 0; text-align: start; }
.notification-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.notification-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.notification-head time { flex: none; color: var(--hint); font-size: 11px; white-space: nowrap; }
.notification-preview { display: block; margin-top: 3px; color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  #view-list > .bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; }
  #view-list > .bar .header-language { grid-column: 2; grid-row: 1; }
  #view-list > .bar .bar-actions { grid-column: 1 / -1; grid-row: 2; margin: 0; flex-wrap: wrap; justify-content: flex-start; }
}

@media (max-width: 390px) {
  .notification-setting { flex-direction: column; align-items: stretch; gap: 8px; }
  .notification-setting button { align-self: flex-end; max-width: 100%; }
  .profile-time-zone-row { display: grid; grid-template-columns: minmax(0, 1fr); }
  .profile-time-zone-row button { justify-self: end; }
  .bar { gap: 4px; padding-inline: 8px; }
  #view-chat > .bar:has(.chat-unread-peers:not(:empty)) { display: grid;
    grid-template-columns: 44px 38px minmax(0, 1fr) auto; gap: 4px; }
  #view-chat > .bar:has(.chat-unread-peers:not(:empty)) #back-btn { grid-column: 1; grid-row: 1; }
  #view-chat > .bar:has(.chat-unread-peers:not(:empty)) #chat-peer-avatar { grid-column: 2; grid-row: 1; }
  #view-chat > .bar:has(.chat-unread-peers:not(:empty)) .grow { grid-column: 3 / -1; grid-row: 1; }
  #view-chat > .bar:has(.chat-unread-peers:not(:empty)) .chat-unread-peers { grid-column: 1 / -2; grid-row: 2; justify-content: flex-end; }
  #view-chat > .bar:has(.chat-unread-peers:not(:empty)) .header-language { grid-column: -2; grid-row: 2; }
  .bar-actions button { padding-inline: 5px; font-size: 13px; }
  #view-list > .bar h2 { font-size: 13px; }
  .account-bar { gap: 5px; padding-inline: 8px; }
  .account-bar label { display: none; }
  .account-bar button { padding-inline: 6px; font-size: 13px; }
  .install-card { margin-inline: 8px; padding: 10px; gap: 8px; }
  .partner-main { gap: 8px; padding-inline: 10px; }
  .relation-list li { flex-wrap: wrap; gap: 6px; }
  .relation-list .meta { flex-basis: 100%; overflow-wrap: anywhere; }
  .state { min-width: 0; }
  .composer { padding-inline: 8px; }
  .row { max-width: 90%; }
}
