/* chat-core.css — 多语言排版、多选、置顶条、分隔线、发送状态、回应、链接卡片、回到底部、消息菜单、查看器、弹层、安全页（由 chat.css 按顺序拆出，层叠顺序不变） */
/* ==========================================================
   chat.css — batch2 新增：多语言排版、消息菜单、回应、置顶条、多选、
   未读线、链接卡片、发送状态、查看器、预览 / 转发 / 删除弹层、安全页
   ========================================================== */

/* ---------- 多语言排版：长词 / 无空格文字安全换行 ---------- */
.bubble, .bubble p, .ci-last, .ci-title, .m-name, .m-sub, .reply-text, .pin-snippet, .ctx-snippet,
.sr-label, .set-group-title, .lc-title, .lc-desc, .login-desc, .btn, .rec-table td {
  word-break: break-word;
  overflow-wrap: anywhere;
  line-break: loose;
}
.btn { white-space: normal; text-align: center; line-height: 1.25; }
/* 分段控件（ux #41）：按钮文字一行、不拆字（英文 Group / Channel 曾被拆成单个字母）；放不下时整个控件换到下一行，而不是挤按钮 */
.seg button { white-space: nowrap; overflow-wrap: normal; word-break: keep-all; text-align: center; line-height: 1.25; min-height: 32px; height: auto; padding-top: 4px; padding-bottom: 4px; }
.info-row:has(> .seg) { flex-wrap: wrap; row-gap: 8px; }
.info-row > .seg { margin-left: auto; }
.info-row:has(> .seg) > div { flex-basis: 150px; }   /* 文字至少留 150px，不够就把控件换到下一行 */
.set-row .seg { max-width: 100%; }
.btn { min-height: 36px; height: auto; padding-top: 6px; padding-bottom: 6px; }
.composer-input textarea { line-height: var(--lh); }
.ci-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 顶栏：普通态 / 多选态 ---------- */
.chat-head { position: relative; }
.head-normal, .head-select { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.head-select { display: none; gap: 8px; }
.chat.selecting .head-normal { display: none; }
.chat.selecting .head-select { display: flex; }
.sel-count { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 置顶条 ---------- */
.pin-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 6px 4px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pin-main { flex: 1; min-width: 0; display: flex; align-items: stretch; gap: 10px; text-align: left; padding: 2px 0; }
.pin-ticks { display: flex; flex-direction: column; gap: 2px; width: 3px; flex-shrink: 0; }
.pin-ticks i { flex: 1; min-height: 6px; border-radius: 2px; background: var(--accent); opacity: .3; }
.pin-ticks i.on { opacity: 1; }
.pin-text { display: flex; flex-direction: column; min-width: 0; }
.pin-title { font-size: 13px; font-weight: 600; color: var(--accent); }
.pin-snippet { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }

/* ---------- 分隔线 ---------- */
.unread-sep {
  display: flex; justify-content: center;
  margin: 8px -16px; padding: 4px 0;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  font-size: 13px; font-weight: 500; color: var(--accent);
}

/* ---------- 消息：选中 / 菜单目标 / 闪烁 ---------- */
.msg { position: relative; border-radius: var(--radius-sm); transition: background .2s; }
.msg-check {
  display: none;
  width: 22px; height: 22px; flex-shrink: 0; align-self: center;
  border-radius: 50%; border: 2px solid var(--border-strong);
  background: var(--bg);
  align-items: center; justify-content: center;
  color: transparent;
}
.msg-check .ti { font-size: 14px; }
.chat.selecting .msg-check { display: inline-flex; order: -1; }
.chat.selecting .msg { cursor: pointer; margin-left: -8px; margin-right: -8px; padding: 2px 8px; }
.chat.selecting .msg.out .msg-check { margin-right: auto; }
.msg.selected { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.msg.selected .msg-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.msg.menu-target .bubble, .msg.menu-target .sticker-msg { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.msg.flash { animation: flash 1s ease; }
@keyframes flash { 0%, 60% { background: color-mix(in srgb, var(--accent) 22%, transparent); } 100% { background: transparent; } }
button.reply { width: calc(100% + 6px); text-align: left; cursor: pointer; }

/* ---------- 发送状态 ---------- */
.st-sending { animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.retry {
  align-self: center; flex-shrink: 0; order: -1;
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; background: var(--danger);
}
.retry .ti { font-size: 20px; }
.msg.out:has(.retry) .bubble { opacity: .85; }
.edited { margin-right: 4px; font-style: italic; }

/* ---------- 表情回应 ---------- */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; clear: both; }
.caption .reactions { margin-top: 2px; }
.react {
  height: 26px; padding: 0 8px 0 6px;
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent); font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
}
.react .re { font-size: 15px; line-height: 1; }
.react.mine { background: var(--accent); color: var(--on-accent); }
.msg.out .react { background: var(--bubble-out-quote); color: var(--bubble-out-text); }
.msg.out .react.mine { background: var(--bubble-out-line); color: var(--bubble-out); }
:root[data-layout="list"] .msg.out .react { background: var(--accent-soft); color: var(--accent); }
:root[data-layout="list"] .msg.out .react.mine { background: var(--accent); color: var(--on-accent); }
.sticker-msg .reactions { justify-content: flex-start; }

/* ---------- 链接 / 链接卡片 / 译文 ---------- */
.bubble .link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg.out .bubble .link { color: inherit; }
.link-card {
  display: flex; gap: 10px; align-items: stretch;
  margin: 6px 0 2px; padding: 6px 8px 6px 6px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  max-width: 360px;
}
.msg.out .link-card { background: var(--bubble-out-quote); border-left-color: var(--bubble-out-line); }
.lc-thumb { width: 56px; height: 56px; flex-shrink: 0; border-radius: 4px; object-fit: cover; }
.lc-body { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.lc-site { color: var(--accent); font-weight: 600; }
.msg.out .lc-site { color: inherit; opacity: .85; }
.lc-title { font-weight: 600; }
.lc-desc { opacity: .8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.translated { margin-top: 6px; padding-top: 6px; border-top: 1px dashed color-mix(in srgb, currentColor 30%, transparent); }
.tr-label { display: flex; align-items: center; gap: 4px; font-size: 12px; opacity: .75; margin-bottom: 2px; }
.tr-label .ti { font-size: 14px; }
.translated p { display: block; }

/* ---------- 回到底部 ---------- */
.chat { position: relative; }
.jump-btn {
  position: absolute; right: 16px; bottom: 84px; z-index: 5;
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-2);
  box-shadow: var(--shadow);
}
.jump-btn .badge { position: absolute; top: -6px; right: -4px; }
.chat:has(.picker.open) .jump-btn { display: none; }

/* ---------- 回复 / 编辑 条 ---------- */
.compose-ctx {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px -2px; padding: 6px 4px 6px 12px;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 1px solid var(--border);
}
.compose-ctx > .ti { color: var(--accent); }
.ctx-text { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 3px solid var(--accent); padding-left: 8px; }
.ctx-title { font-size: 13px; font-weight: 600; color: var(--accent); }
.ctx-snippet { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose-ctx:not([hidden]) + .composer .composer-input { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ---------- 消息菜单 ---------- */
.msg-menu {
  position: fixed; z-index: 80;
  width: 248px; padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.react-row, .react-more { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.react-more { grid-template-columns: repeat(8, 1fr); }
.rq {
  height: 32px; border-radius: var(--radius-sm);
  font-size: 19px; line-height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.rq:hover { background: var(--bg-hover); }
.rq.on { background: var(--accent-soft); }
.rq.more { color: var(--text-2); font-family: inherit; }
.rq.more .ti { font-size: 18px; }
.mm-list button {
  width: 100%; min-height: 38px; padding: 6px 10px;
  display: flex; align-items: center; gap: 12px;
  border-radius: var(--radius-sm); font-size: 14px; text-align: left;
}
.mm-list button .ti { font-size: 19px; color: var(--text-2); }
.mm-list button:hover { background: var(--bg-hover); }
.mm-list button.danger, .mm-list button.danger .ti { color: var(--danger); }

/* ---------- 图片查看器 ---------- */
.viewer { position: fixed; inset: 0; z-index: 120; background: rgba(8, 12, 16, .97); color: #fff; display: flex; flex-direction: column; }
.viewer[hidden] { display: none; }
.viewer-bar {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px 16px;
}
.viewer-count { font-size: 14px; opacity: .85; }
.viewer-actions { display: flex; align-items: center; gap: 2px; }
.viewer .icon-btn { color: rgba(255, 255, 255, .85); }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.viewer-zoom { min-width: 48px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; opacity: .85; }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 12px 64px calc(24px + env(safe-area-inset-bottom)); touch-action: pan-y; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .18s ease; border-radius: 4px; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45); color: #fff;
}
.viewer-nav:hover { background: rgba(0, 0, 0, .65); }
.viewer-nav:disabled { opacity: .25; }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }
.viewer-nav .ti { font-size: 28px; }
body.no-scroll { overflow: hidden; }

/* ---------- 弹层通用 ---------- */
.dlg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dlg-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dlg-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-sub { font-size: 13px; color: var(--text-2); }
.file-icon.sm { width: 36px; height: 36px; border-radius: var(--radius-sm); }
.file-icon.sm .ti { font-size: 20px; }
.dlg-options { display: flex; flex-direction: column; gap: 8px; }
.dlg-options .btn { width: 100%; height: 42px; }
.dlg-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.dlg-icon.warn { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.dlg-icon .ti { font-size: 26px; }
.modal-actions { gap: 10px; align-items: center; }
.modal-actions .btn { text-decoration: none; }

.modal.preview { width: min(560px, calc(100vw - 32px)); }
.pv-body { max-height: 60vh; overflow-y: auto; margin: 0 -20px 16px; padding: 12px 20px; background: var(--bg-soft); display: flex; flex-direction: column; gap: 12px; }
.pv-page { margin: 0; text-align: center; }
.pv-page img { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.pv-page figcaption, .pv-note { font-size: 12px; color: var(--text-3); text-align: center; margin: 4px 0 0; }
.pv-img { max-width: 100%; border-radius: 4px; align-self: center; }
.pv-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 0; color: var(--text-3); }
.pv-empty .ti { font-size: 40px; }

.modal.forward { width: min(420px, calc(100vw - 32px)); }
.modal.forward .pk-search { margin: 0 0 8px; }
.fw-list { max-height: 50vh; overflow-y: auto; margin: 0 -8px 12px; }
.fw-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.fw-item:hover { background: var(--bg-hover); }
.fw-item .m-body { display: flex; flex-direction: column; }
.fw-check { width: 20px; height: 20px; flex-shrink: 0; }
.fw-count { flex: 1; font-size: 13px; color: var(--text-2); }

/* ---------- 登录：锁定 / 语言 ---------- */
.login-alert {
  display: flex; align-items: flex-start; gap: 8px; text-align: left;
  margin: -8px 0 20px; padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger); font-size: 14px; font-weight: 500;
}
.login-alert .ti { font-size: 18px; margin-top: 1px; }
.login :disabled { opacity: .55; cursor: not-allowed; }
.login-lang {
  margin-top: 28px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2);
}
.login-lang .ti { font-size: 18px; }
.login-lang select { border: 0; background: none; color: var(--text-2); font-size: 14px; padding: 6px 2px; outline: none; }
.list-empty { padding: 24px 16px; text-align: center; color: var(--text-3); font-size: 14px; }

/* ---------- 安全：当前设备 + 登录记录 ---------- */
.cur-device { display: flex; gap: 16px; padding: 10px 16px 14px; }
.cur-icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--online) 15%, transparent); color: var(--online); }
.cur-icon .ti { font-size: 26px; }
.cur-grid { flex: 1; min-width: 0; margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.cur-grid dt { color: var(--text-2); }
.cur-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.rec-wrap { overflow-x: auto; padding: 0 0 8px; }
.rec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rec-table th { text-align: left; font-weight: 600; color: var(--text-2); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rec-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.rec-table th:first-child, .rec-table td:first-child { padding-left: 16px; white-space: nowrap; }
.rec-table tr.rec-fail td, .rec-table tr.rec-locked td { background: color-mix(in srgb, var(--danger) 8%, var(--bg)); }
.rec-badge { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.rec-badge .ti { font-size: 16px; }
.rec-ok .rec-badge { color: var(--online); }
.rec-fail .rec-badge, .rec-locked .rec-badge { color: var(--danger); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* 投票：发送键灰着时旁边的原因（ux #42） */
#pollDlg .modal-actions { align-items: center; gap: 12px; }
.poll-why { flex: 1; font-size: 13px; color: var(--text-3); text-align: right; }
