/* 小鱼聊天 · 界面样式
   深色、克制、信息优先——跟小鱼「干练、不废话」的调子一致 */

:root {
  color-scheme: dark;   /* 让原生控件（audio 播放器、滚动条）也走深色 */
  --bg: #0e1014;
  --panel: #14171d;
  --panel-2: #1a1e26;
  --border: #232833;
  --text: #e8eaf0;
  --text-dim: #9aa4b6;
  --muted: #6d7788;
  --me: #1f6feb;
  --me-text: #ffffff;
  --them: #222833;
  --accent: #3b82f6;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 16px;
  --topbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; opacity: .45; }

::selection { background: rgba(59, 130, 246, .35); }

/* 滚动条 */
.scroller { scrollbar-width: thin; scrollbar-color: #2f3542 transparent; }
.scroller::-webkit-scrollbar { width: 8px; }
.scroller::-webkit-scrollbar-thumb { background: #2f3542; border-radius: 4px; }
.scroller::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- 视图 */
.view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
}

/* ------------------------------------------------------------ 登录界面 */
#pair-view {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.pair-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 26px 26px;
  text-align: center;
}

.brand { margin-bottom: 18px; }
.brand-mark {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1f6feb, #0b4aa8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(31, 111, 235, .28);
}
.brand-mark svg { display: block; }

.brand h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .5px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
  line-height: 1.6;
}
.hint code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-dim);
}

.code-input {
  width: 100%;
  padding: 14px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 24px;
  letter-spacing: .26em;
  text-indent: .26em;
  text-align: center;
  outline: none;
  transition: border-color .15s;
}
.code-input:focus { border-color: var(--accent); }
.code-input::placeholder { color: var(--placeholder); letter-spacing: .2em; }

.btn-primary {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border-radius: 12px;
  background: var(--me);
  color: var(--me-text);
  font-size: 15px;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--me-hover); }

.error {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}

.peer { display: flex; align-items: center; gap: 10px; min-width: 0; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, #1f6feb, #0b4aa8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.peer-meta { min-width: 0; }
.peer-name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.peer-status {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 5px;
}
.peer-status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  transition: background .2s;
}
.peer-status.online::before { background: var(--ok); }
.peer-status.connecting::before { background: #fbbf24; }
.peer-status.offline::before { background: var(--danger); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* 下拉菜单 */
.dropdown {
  position: absolute;
  top: calc(var(--topbar-h) + env(safe-area-inset-top) - 6px);
  right: 12px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--dropdown-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  z-index: 60;
  min-width: 150px;
}
.dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-dim);
}
.dropdown button:hover { background: var(--panel-2); color: var(--text); }
.menu-ver {
  padding: 8px 12px 4px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 4px;
  white-space: nowrap;
}

/* -------------------------------------------------------------- 消息区 */
.scroller {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
}

/* 消息少的时候贴着输入框往下排，而不是浮在顶部 */
.messages {
  display: flex;
  flex-direction: column;
  margin-top: auto;
}

/* 空状态：撑满高度并垂直居中 */
.messages.is-empty {
  margin-top: 0;
  flex: 1 1 auto;
  justify-content: center;
  align-items: center;
}
.messages.is-empty::before {
  content: "还没有消息\A 在下面发一句试试";
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.9;
  text-align: center;
  padding: 20px;
}

.loading-more {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0 14px;
}

/* 日期分隔 */
.day-sep {
  align-self: center;
  margin: 14px 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--chip-bg);
  padding: 2px 10px;
  border-radius: 99px;
}

/* 一条消息 */
.msg {
  display: flex;
  flex-direction: column;
  margin: 6px 0;
  max-width: 100%;
  animation: msg-in .16s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.msg.me { align-items: flex-end; }
.msg.them { align-items: flex-start; }
.msg.gap { margin-top: 12px; }

.bubble strong { font-weight: 650; }
.bubble code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 5px;
}

.bubble {
  position: relative;
  max-width: min(78%, 560px);
  padding: 9px 13px;
  border-radius: var(--radius);
  font-size: 15px;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msg.them .bubble {
  background: var(--them);
  border: 1px solid var(--bubble-border);
  border-bottom-left-radius: 5px;
  color: var(--text);
}

.msg.me .bubble {
  background: var(--me);
  border-bottom-right-radius: 5px;
  color: var(--me-text);
}

.msg.pending .bubble { opacity: .6; }
.msg.failed .bubble { background: var(--failed-bg); }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 4px 0;
  font-size: 11px;
  color: var(--muted);
  /* 移动端没有 hover，时间必须常显，否则对方的消息永远看不到几点发的 */
  opacity: .5;
  transition: opacity .15s;
}
.msg:hover .msg-meta { opacity: .9; }
.msg.me .msg-meta { opacity: .7; }
.msg .sender { color: var(--text-dim); }

/* 系统消息 */
.sys-msg {
  align-self: center;
  margin: 10px 0;
  font-size: 12px;
  color: var(--muted);
  background: var(--chip-bg);
  padding: 3px 12px;
  border-radius: 99px;
  text-align: center;
  max-width: 86%;
}

/* 图片气泡：去掉边框和底色，让图片自己圆角，画面更干净 */
.msg .bubble.img-bubble {
  padding: 0;
  background: transparent;
  border: 0;
  line-height: 0;
}
.bubble.img-bubble img {
  display: block;
  max-width: 220px;
  max-height: 280px;
  width: auto;
  border-radius: 14px;
  cursor: zoom-in;
  background: var(--img-bg);
}
.img-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 110px;
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  padding: 8px;
}

/* 文件气泡 */
.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 180px;
  max-width: 300px;
  text-decoration: none;
  color: inherit;
}
.file-icon {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--hover-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.5px;
}
.msg.them .file-icon { background: rgba(255, 255, 255, .07); }
.file-body { min-width: 0; flex: 1; }
.file-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size { font-size: 11.5px; opacity: .7; }
.file-dl { font-size: 12px; opacity: .8; flex: 0 0 auto; }

/* 语音 */
.audio-bubble {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 170px;
  color-scheme: dark;
}
.audio-bubble audio { width: 235px; height: 34px; }

/* 跳到最新 */
.jump-latest {
  position: absolute;
  right: 16px;
  bottom: 84px;
  padding: 7px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12.5px;
  color: var(--text-dim);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
  z-index: 30;
}
.jump-latest:hover { color: var(--text); }

/* -------------------------------------------------------------- 输入区 */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 12px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
}

#input {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 132px;
  padding: 9px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;      /* 16px 起：避免移动端聚焦自动放大 */
  line-height: 1.45;
  resize: none;
  overflow-y: hidden;
  outline: none;
  transition: border-color .15s;
}
#input:focus { border-color: var(--input-focus-border); }
#input::placeholder { color: var(--muted); }

.send-btn {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 17px;
  border-radius: 20px;
  background: var(--me);
  color: var(--me-text);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, opacity .15s;
}
.send-btn:hover:not(:disabled) { background: var(--me-hover); }
/* 禁用态用灰而不是半透明，否则看着像"能点但颜色怪" */
.send-btn:disabled {
  background: var(--btn-disabled);
  color: var(--btn-disabled-text);
  opacity: 1;
}

/* 拖拽遮罩 */
.drop-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 40, 80, .55);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  margin: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #cfe0ff;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

/* ---------------------------------------------------------------- 大图 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* ---------------------------------------------------------------- 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 120;
  background: var(--toast-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 99px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  max-width: calc(100% - 40px);
  text-align: center;
}

/* ------------------------------------------------------------ 桌面端 */
@media (min-width: 781px) {
  body { background: var(--desktop-bg); }
  .view {
    background: var(--bg);
    border-left: 1px solid var(--desktop-border);
    border-right: 1px solid var(--desktop-border);
    box-shadow: var(--desktop-shadow);
  }
  .bubble { max-width: min(74%, 520px); }
  .topbar { padding-left: 20px; padding-right: 20px; }
  .scroller { padding-left: 20px; padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ============================================================
   亮色主题：每天 07:00–23:00 自动生效（由 app.js 按本地时间切换）
   ============================================================ */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f2f4f7;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --border: #e5e9ef;
  --text: #15171c;
  --text-dim: #4a5261;
  --muted: #8a93a3;

  --me: #1f6feb;
  --me-text: #ffffff;
  --me-hover: #1a62d2;
  --them: #ffffff;
  --accent: #1f6feb;
  --danger: #dc2626;
  --ok: #16a34a;

  --dropdown-bg: #ffffff;
  --toast-bg: #ffffff;
  --desktop-bg: #e7eaf0;
  --desktop-border: #dfe3ea;
  --desktop-shadow: 0 0 60px rgba(16, 24, 40, .10);
  --img-bg: #eef1f5;
  --btn-disabled: #eaeef3;
  --btn-disabled-text: #a9b2c0;
  --input-focus-border: #b7c5dc;
  --hover-overlay: rgba(15, 23, 42, .05);
  --code-bg: rgba(15, 23, 42, .06);
  --chip-bg: rgba(15, 23, 42, .045);
  --placeholder: #a9b2c0;
  --failed-bg: #fde8e8;
  --bubble-border: #eef1f5;
}

/* 亮色下几处细节调整 */
:root[data-theme="light"] .msg.them .bubble {
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
:root[data-theme="light"] .topbar {
  box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
  border-bottom-color: transparent;
}
:root[data-theme="light"] .composer {
  box-shadow: 0 -1px 3px rgba(16, 24, 40, .04);
  border-top-color: transparent;
}
:root[data-theme="light"] .dropdown {
  box-shadow: 0 10px 30px rgba(16, 24, 40, .14);
}
:root[data-theme="light"] .toast {
  box-shadow: 0 8px 24px rgba(16, 24, 40, .16);
}
:root[data-theme="light"] .drop-mask {
  background: rgba(31, 111, 235, .12);
  color: #1f6feb;
}
:root[data-theme="light"] .lightbox {
  background: rgba(255, 255, 255, .96);
}
:root[data-theme="light"] .bubble.img-fallback {
  border: 1px solid var(--bubble-border);
}

/* 主题切换的过渡（只过渡颜色，不动布局，避免卡顿） */
body, .topbar, .composer, .bubble, .dropdown, .toast {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* 发送失败的消息：点一下重发 */
.msg.failed .bubble {
  cursor: pointer;
  opacity: .92;
}
.msg.failed .bubble:hover {
  opacity: 1;
}
.retry-hint {
  color: var(--danger) !important;
  font-weight: 500;
}
/* 音频消息：播放器 + 明确的下载按钮 */
.audio-bubble {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 220px;
}
.audio-bubble audio {
  width: 100%;
}
.audio-dl {
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background-color .15s;
}
.audio-dl:hover {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--chip-bg);
}
.audio-dl:active {
  transform: scale(.97);
}
/* ---------------------------------------------------- 账号 / 同意 / 角色 */

.brand-li {
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; letter-spacing: -1px;
  color: #fff; background: var(--brand, #1652b4);
  border-radius: 14px; width: 64px; height: 64px;
  font-family: "STKaiti", "KaiTi", serif;
}
.brand-li.small { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; }

.btn-link {
  background: none; border: none; padding: 10px 0;
  color: var(--text-dim, #667); font-size: 14px;
  text-decoration: underline; cursor: pointer;
}

.consent-card {
  max-width: 420px; margin: auto; padding: 32px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.consent-card h2 { font-size: 20px; margin: 0 0 6px; }
.consent-text { font-size: 15px; line-height: 1.7; color: var(--text, #222); margin: 0; }
.consent-text.muted { color: var(--text-dim, #889); font-size: 14px; }

.agent-list {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.agent-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 16px; text-align: left;
  background: var(--card, #fff); border: 1px solid var(--line, #e6e8ec);
  border-radius: 16px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.agent-card:active { transform: scale(.985); }
.agent-card.placeholder { opacity: .6; }
.agent-avatar {
  width: 48px; height: 48px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: #fff; background: #1652b4;
}
.agent-xiaotong_admin,
.agent-xiaotong_lite { background: #f06292; }
.agent-xiaoyu_admin,
.agent-xiaoyu_lite { background: #1652b4; }
.agent-liyuchen { background: #2f6f5e; font-family: "STKaiti","KaiTi",serif; }
.agent-meta { flex: 1; min-width: 0; }
.agent-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.agent-badge {
  font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 99px;
  background: rgba(22,82,180,.1); color: #1652b4;
}
.agent-desc { font-size: 13px; color: var(--text-dim, #889); margin-top: 3px; }
.empty-hint { padding: 40px 20px; text-align: center; color: var(--text-dim, #889); font-size: 14px; line-height: 1.7; }

html[data-theme="dark"] .agent-card { background: #171a20; border-color: #262b34; }
html[data-theme="dark"] .consent-text { color: #d5d9e0; }

/* ---------------------------------------------------- 新一轮聊天界面 */

.xy-msg {
  display: flex; margin: 6px 12px;
  animation: xy-in .18s ease;
}
.xy-msg.out { justify-content: flex-end; }
.xy-msg.in { justify-content: flex-start; }
.xy-msg.sys { justify-content: center; }

.xy-bubble {
  max-width: 78%; padding: 9px 13px;
  font-size: 15px; line-height: 1.55;
  border-radius: 16px; word-break: break-word;
  white-space: pre-wrap;
}
.xy-msg.out .xy-bubble {
  background: var(--brand, #1652b4); color: #fff;
  border-bottom-right-radius: 5px;
}
.xy-msg.in .xy-bubble {
  background: var(--card, #fff); color: var(--text, #222);
  border: 1px solid var(--line, #e6e8ec);
  border-bottom-left-radius: 5px;
}
.xy-msg.sys .xy-bubble {
  background: transparent; color: var(--text-dim, #889);
  font-size: 13px; max-width: 90%; text-align: center; border: none;
}
.xy-msg.failed .xy-bubble { opacity: .55; }

@keyframes xy-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

html[data-theme="dark"] .xy-msg.in .xy-bubble {
  background: #1b1f27; border-color: #2a303a; color: #e3e7ee;
}

/* ---------------------------------------------------- 下载文件卡片 */

.xy-file {
  display: flex; align-items: center; gap: 12px;
  max-width: 84%; padding: 11px 13px;
  background: var(--card, #fff); border: 1px solid var(--line, #e6e8ec);
  border-radius: 15px;
}
.xy-msg.out .xy-file { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.22); }
.xy-msg.out .xy-file-name { color: #fff; }
.xy-msg.out .xy-file-sub { color: rgba(255,255,255,.7); }

.xy-file-icon {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: rgba(22,82,180,.1); color: #1652b4;
}
.xy-msg.out .xy-file-icon { background: rgba(255,255,255,.18); color: #fff; }

.xy-file-meta { flex: 1; min-width: 0; }
.xy-file-name {
  font-size: 14px; font-weight: 500; color: var(--text, #222);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.xy-file-sub { font-size: 12px; color: var(--text-dim, #889); margin-top: 2px; }

.xy-file-btn {
  flex: none; padding: 7px 14px; border-radius: 9px; border: none;
  background: var(--brand, #1652b4); color: #fff;
  font-size: 13px; cursor: pointer;
}
.xy-msg.in .xy-file-btn { background: var(--brand, #1652b4); }

html[data-theme="dark"] .xy-file { background: #1b1f27; border-color: #2a303a; }
html[data-theme="dark"] .xy-file-name { color: #e3e7ee; }

.xy-bubble strong { font-weight: 600; }
.xy-bubble code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px; padding: 1px 5px; border-radius: 5px;
  background: rgba(0,0,0,.06);
}
html[data-theme="dark"] .xy-bubble code { background: rgba(255,255,255,.1); }

/* 单字头像：字要够大才好看 */
.agent-avatar {
  font-family: "STKaiti", "KaiTi", "PingFang SC", serif;
  font-size: 22px; font-weight: 500; letter-spacing: 0;
}
.agent-liyuchen { background: #2f6f5e; }

/* 单字头像（聊天页顶部） */
.avatar-char {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: "STKaiti", "KaiTi", "PingFang SC", serif;
  font-size: 17px; font-weight: 500;
  background: var(--brand, #1652b4); color: #fff;
}
.avatar-char.agent-xiaotong_admin,
.avatar-char.agent-xiaotong_lite { background: #f06292; }
.avatar-char.agent-liyuchen { background: #2f6f5e; }
#btn-back { font-size: 24px; line-height: 1; padding: 0 6px; }

/* ---------------------------------------------------- 版本更新弹窗 */

.update-wrap {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(10,14,22,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: xy-fade .18s ease;
}
.update-card {
  width: 100%; max-width: 340px;
  background: var(--card, #fff);
  border-radius: 18px; padding: 24px 22px 18px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
  animation: xy-pop .2s cubic-bezier(.2,.9,.3,1.2);
}
.update-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.update-body { font-size: 14px; color: var(--text, #222); }
.update-body b { color: var(--brand, #1652b4); font-weight: 600; }
.update-note { font-size: 12px; color: var(--text-dim, #889); margin-bottom: 12px; }
.update-card .btn-primary { margin-top: 6px; }
.update-card .btn-link { margin-top: 2px; }

@keyframes xy-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes xy-pop { from { opacity: 0; transform: scale(.94) } to { opacity: 1; transform: none } }

html[data-theme="dark"] .update-card { background: #1b1f27; }

/* 登录/注册输入框：placeholder 太长会被截，缩小一点并留出内边距 */
#auth-phone, #auth-password, #auth-nickname {
  padding-left: 14px; padding-right: 14px;
}
#auth-nickname::placeholder {
  font-size: 14px;
  letter-spacing: 0;
}
#auth-phone::placeholder,
#auth-password::placeholder {
  font-size: 15px;
}

/* 返回箭头放在头像左边，贴住屏幕左缘 */
.back-btn {
  font-size: 26px; line-height: 1;
  padding: 0 4px 0 0;
  margin-right: 2px;
  color: var(--text, #222);
}

/* 更新说明列表 */
.up-notes {
  display: flex; flex-direction: column; gap: 5px;
  margin: 6px 0 10px;
  padding: 10px 12px;
  background: rgba(22,82,180,.06);
  border-radius: 10px;
  max-height: 160px; overflow-y: auto;
}
.up-note {
  font-size: 13px; line-height: 1.5;
  color: var(--text, #222);
}
html[data-theme="dark"] .up-notes { background: rgba(100,160,255,.09); }
html[data-theme="dark"] .up-note { color: #d5d9e0; }


/* 登录页和同意页要正中，不能贴左上角（.view 只设了纵向排列，没设居中） */
#auth-view, #consent-view {
  justify-content: center;
  align-items: center;
  padding: 24px;
}
#auth-view .pair-card,
#consent-view .consent-card {
  margin: 0 auto;
}

/* ---------------------------------------------------- 时间戳 */

.xy-time {
  align-self: flex-end;
  flex: none;
  font-size: 11px;
  color: var(--text-dim, #9aa3b2);
  margin: 0 6px 2px;
  white-space: nowrap;
  user-select: none;
}
.xy-msg.out .xy-time { order: -1; }     /* 自己发的，时间放左边 */
.xy-msg.in  .xy-time { order: 1; }      /* 对方发的，时间放右边 */

/* ---------------------------------------------------- 正在输入 */

.xy-typing .xy-bubble {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 14px;
  min-width: 52px;
}
.xy-typing .xy-bubble span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim, #9aa3b2);
  animation: xy-typing 1.2s infinite ease-in-out;
}
.xy-typing .xy-bubble span:nth-child(2) { animation-delay: .18s }
.xy-typing .xy-bubble span:nth-child(3) { animation-delay: .36s }

@keyframes xy-typing {
  0%, 60%, 100% { opacity: .35; transform: translateY(0) }
  30%           { opacity: 1;   transform: translateY(-3px) }
}
html[data-theme="dark"] .xy-typing .xy-bubble span { background: #8b95a7; }

/* ---------------------------------------------------- 聊天搜索栏 */

.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--panel, #fff);
  border-bottom: 1px solid var(--line, #e6e8ec);
  animation: xy-slide-down .16s ease;
}
.search-field {
  flex: 1; padding: 9px 13px; box-sizing: border-box;
  border: 1px solid var(--line, #e6e8ec); border-radius: 10px;
  background: var(--bg, #f5f7fa); color: var(--text, #222); font-size: 15px;
}
.search-field:focus { outline: 2px solid rgba(22,82,180,.26); border-color: var(--brand); }
@keyframes xy-slide-down { from { opacity: 0; transform: translateY(-6px) } to { opacity: 1; transform: none } }

/* ---------------------------------------------------- 记忆面板 */

.mem-wrap {
  position: fixed; inset: 0; z-index: 250;
  background: var(--bg, #f5f7fa);
  display: flex; flex-direction: column;
  animation: xy-slide-up .2s cubic-bezier(.2,.9,.3,1);
}
.mem-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px;
  background: var(--panel, #fff);
  border-bottom: 1px solid var(--line, #e6e8ec);
}
.mem-title { flex: 1; font-size: 16px; font-weight: 600; text-align: center; }
.mem-sub {
  padding: 10px 18px 4px; font-size: 13px; color: var(--text-dim, #889);
}
.mem-list { flex: 1; overflow-y: auto; padding: 8px 14px 20px; }
.mem-row {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card, #fff);
  border: 1px solid var(--line, #e6e8ec);
  border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px;
}
.mem-text { flex: 1; font-size: 14px; line-height: 1.6; word-break: break-word; }
.mem-del {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(220,80,60,.1); color: #c0392b;
  font-size: 17px; line-height: 1; cursor: pointer;
}
.mem-del:active { background: rgba(220,80,60,.2); }
.mem-del:disabled { opacity: .4; }
.mem-tip {
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  font-size: 12px; color: var(--text-dim, #889); text-align: center;
  border-top: 1px solid var(--line, #e6e8ec);
  background: var(--panel, #fff);
}
@keyframes xy-slide-up { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }

html[data-theme="dark"] .mem-row { background: #1b1f27; border-color: #2a303a; }
html[data-theme="dark"] .mem-head,
html[data-theme="dark"] .mem-tip { background: #14171d; border-color: #262b34; }


/* 记忆面板底部的输入行 */
.mem-add {
  display: flex; gap: 8px;
  padding: 10px 14px;
  background: var(--panel, #fff);
  border-top: 1px solid var(--line, #e6e8ec);
}
#mem-input {
  flex: 1; padding: 10px 13px; box-sizing: border-box;
  border: 1px solid var(--line, #e6e8ec); border-radius: 10px;
  background: var(--bg, #f5f7fa); color: var(--text, #222); font-size: 14px;
}
#mem-input:focus { outline: 2px solid rgba(22,82,180,.26); border-color: var(--brand); }
#mem-add {
  flex: none; padding: 0 18px; border: none; border-radius: 10px;
  background: var(--brand, #1652b4); color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
#mem-add:disabled { opacity: .5; }
html[data-theme="dark"] .mem-add { background: #14171d; border-color: #262b34; }

/* 顶部「正在加载更早的消息」提示 */
.history-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim, #9aa3b2);
  padding: 10px 16px 6px;
  user-select: none;
}
.history-hint.hidden { display: none; }

/* ---------------------------------------------------- 加载失败重试 */

.retry-box {
  margin: auto;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  padding: 30px 24px;
  text-align: center;
}
.retry-title { font-size: 16px; font-weight: 600; color: var(--text, #222); }
.retry-sub {
  font-size: 13px; color: var(--text-dim, #889);
  line-height: 1.6; word-break: break-all;
  max-width: 260px;
}
.retry-btn {
  margin-top: 10px; padding: 11px 34px;
  border: none; border-radius: 999px;
  background: var(--brand, #1652b4); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.retry-btn:active { opacity: .82; }
html[data-theme="dark"] .retry-title { color: #e8eaee; }
html[data-theme="dark"] .retry-sub { color: #8b95a7; }

/* 返回键：44×44 是触控最小尺寸，原来 38 太小 */
.back-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1;
  padding: 0; margin-right: 0;
}


/* 密码框 + 显示切换 */
.pw-field { position: relative; width: 100%; }
.pw-field .code-input { padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: none; color: var(--text-dim, #889);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pw-toggle.on { color: var(--brand, #1652b4); }
.pw-toggle:active { background: rgba(120,140,180,.12); }


/* 菜单分组 */
.menu-group-label {
  padding: 8px 14px 4px;
  font-size: 11px; font-weight: 600;
  color: var(--text-dim, #98a1b0);
  letter-spacing: .04em;
  user-select: none;
}
.menu-sep {
  height: 1px; margin: 6px 10px;
  background: var(--line, #e6e8ec);
}
#menu .menu-danger { color: #d0453a; }
html[data-theme="dark"] .menu-sep { background: #2a303a; }
html[data-theme="dark"] #menu .menu-danger { color: #ff7a6b; }
