/* 鱼塘聊天室 - 摸鱼基地（挂载进主站 SPA 的组件样式）
 * 浅色玻璃主题：色板/间距/圆角全部引用主站 v2 设计令牌（tokens.css），
 * 与「岛屿潮汐」面板风格统一；不再使用主站 .liquid-glass 深色描边。 */

/* 变量作用域限定在 .chat-root，避免 :root 全局泄漏污染主站 */
.chat-root {
  --accent: var(--sea-600);
  --accent-soft: oklch(0.54 0.084 183 / 0.12);
  --text: var(--ink-900);
  --text-sub: var(--ink-700);
  --text-faint: var(--ink-500);
  --border: var(--line);
  --mine: var(--sea-100);
  --mine-border: var(--sea-300);
  --danger: var(--coral-700);

  height: 100%;
  color: var(--text);
  font-family: var(--font-sans);
}

/* ===== 挂载容器 =====
 * chatMount 直接放在 .page-split 里（无外层玻璃面板，侧栏/聊天列自带玻璃底）
 * 高度 = 视口 - page-split 上下留白(6.25rem + 2.5rem)
 * 里面全部自然流式：main 撑满 → chat-col 纵向 flex →
 * 消息流 flex:1 自动滚动（= chat-col 高 - 输入区高），输入区天然贴底 */
.chat-view { height: 100vh; overflow: hidden; }
.chat-view .page-split { padding: 6.25rem 1.5rem 2.5rem; }
#chatMount { height: calc(100vh - 8.75rem); min-height: 480px; width: 100%; max-width: 1180px; margin: 0 auto; }
@media (max-width: 768px) {
  .chat-view { height: auto; overflow: visible; }
  #chatMount { height: 70vh; }
}

/* ===== 通用 ===== */
/* 连接状态提示：位于侧栏标题下方，只占侧栏空间，不影响聊天列 */
.conn-tip { padding: 0 var(--s-4) var(--s-2); font-size: 12px; color: var(--coral-700); font-weight: 600; }
.login-btn {
  background: linear-gradient(135deg, var(--sea-500), var(--sea-700)); color: #fff; border: none; cursor: pointer;
  padding: 7px 18px; border-radius: var(--r-md); font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 14px oklch(0.455 0.072 183 / 0.35);
}

/* ===== 主体 ===== */
.main { height: 100%; display: flex; min-height: 0; gap: var(--s-3); padding: 0; position: relative; }

/* 在线列表（.chat-root 前缀：主站 components.css 后加载且同名 class，需提特异性） */
.chat-root .sidebar {
  width: 220px; border-radius: var(--r-lg);
  display: flex; flex-direction: column; flex-shrink: 0;
  background: var(--paper); border: 1px solid var(--line);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.sidebar-title { padding: 14px var(--s-4) var(--s-2); font-size: 12px; color: var(--text-sub); font-weight: 600; }
.online-list { flex: 1; overflow-y: auto; padding: 0 var(--s-2) var(--s-3); }
.online-item {
  display: flex; align-items: center; gap: var(--s-2); padding: 6px var(--s-2);
  border-radius: var(--r-sm); cursor: pointer; user-select: none;
}
.online-item:hover { background: var(--sea-50); }
.online-item .n { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-item .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-left: auto; flex-shrink: 0;
}
/* 无图头像的 emoji（原模板内联 style 收编至此） */
.avatar-emoji { font-size: 22px; line-height: 1; }

/* 聊天列：纵向 flex，消息流自动占满剩余高度，输入区天然贴底 */
.chat-root .chat-col {
  flex: 1; position: relative; display: flex; flex-direction: column; min-width: 0;
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--paper); border: 1px solid var(--line);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}

/* 公告栏：顶部横向跑马灯，浅蓝底醒目样式，两端渐隐遮罩，悬停暂停 */
.notice-bar {
  display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0;
  margin: 10px 12px 0; padding: 7px 12px;
  background: #E6F4FF;
  border: 1px solid #B8DCFF;
  border-radius: var(--r-sm);
}
.notice-icon { font-size: 14px; flex-shrink: 0; }
.notice-track {
  flex: 1; overflow: hidden; white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
}
.notice-scroll {
  display: inline-flex; animation: notice-marquee 32s linear infinite;
}
.notice-bar:hover .notice-scroll { animation-play-state: paused; }
.notice-item { font-size: 13px; color: #154E8C; font-weight: 500; margin-right: 56px; }
@keyframes notice-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }   /* 内容渲染两份，位移一半即无缝循环 */
}

/* 消息流：flex:1 = chat-col 高度 - 输入区高度 */
.msg-flow { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-4) var(--s-5); }
.flow-tip { text-align: center; font-size: 12px; color: var(--text-faint); padding: 6px 0 10px; }
.day-divider { text-align: center; margin: 10px 0; }
.day-divider span {
  font-size: 12px; color: var(--text-faint); background: var(--sea-50);
  border: 1px solid var(--line);
  padding: 2px 12px; border-radius: var(--r-full);
}
.msg-row { display: flex; gap: 10px; margin-bottom: 14px; position: relative; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-body { max-width: 62%; display: flex; flex-direction: column; align-items: flex-start; }
.msg-row.mine .msg-body { align-items: flex-end; }
.msg-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12px; }
.msg-row.mine .msg-meta { flex-direction: row-reverse; }
.msg-meta .nick { font-weight: 600; color: var(--text-sub); }
/* 时间 + 操作按钮同一行 */
.msg-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.msg-row.mine .msg-foot { justify-content: flex-end; }
.msg-time { font-size: 11px; color: var(--text-faint); font-family: "SimHei", "Heiti SC", "Microsoft YaHei", system-ui, sans-serif; }
.msg-row.mine .msg-time { text-align: right; }
.badge-pill { font-size: 11px; padding: 1px 7px; border-radius: 9px; color: #fff; font-weight: 600; }

/* 气泡：浅色玻璃底 + 细边框，他人白、自己浅绿，靠色相区分 */
.bubble {
  position: relative; border-radius: 4px var(--r-md) var(--r-md) var(--r-md);
  padding: 9px 13px;
  font-size: 14px; line-height: 1.6; word-break: break-word; white-space: pre-wrap;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
}
.msg-row.mine .bubble {
  border-radius: var(--r-md) 4px var(--r-md) var(--r-md);
  background: var(--mine);
  border-color: var(--mine-border);
}
.bubble .at-hl {
  color: var(--accent); font-weight: 600; background: var(--accent-soft);
  border-radius: 3px; padding: 0 2px;
}
.bubble img.pic { max-width: 240px; max-height: 200px; border-radius: var(--r-sm); display: block; cursor: zoom-in; }

/* 引用块：浅底 + accent 左线条 */
.quote-block {
  background: var(--sea-50);
  border-left: 3px solid var(--accent);
  border-radius: 4px var(--r-sm) var(--r-sm) 4px;
  padding: 5px 9px; margin-bottom: 6px;
  font-size: 12px; color: var(--text-sub);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
}
.quote-block:hover { background: var(--sea-100); }
.quote-block b { color: var(--accent); font-weight: 600; }
/* 引用图片缩略图（quote-block / quote-draft 共用） */
.quote-pic {
  display: inline-block; vertical-align: middle;
  max-height: 64px; max-width: 120px; margin-left: 6px;
  border-radius: 4px; object-fit: cover; cursor: zoom-in;
}

/* 撤回占位 */
.msg-row .revoked {
  font-size: 12px; color: var(--text-faint);
  background: var(--sea-50); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: var(--r-full);
}

/* 悬停操作：跟在时间后面的彩色小按钮 */
.msg-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity var(--d-fast) var(--ease-out); }
.msg-row:hover .msg-actions { opacity: 1; }
.msg-actions button {
  border: 1px solid; background: #fff; cursor: pointer;
  font-size: 12px; padding: 1px 9px; border-radius: 11px;
}
.msg-actions .act-quote  { color: #2f7fd1; border-color: #a8cdf0; }
.msg-actions .act-quote:hover  { background: #eaf3fc; }
.msg-actions .act-repeat { color: #2e9e6b; border-color: #a5dcc3; }
.msg-actions .act-repeat:hover { background: #e9f7f0; }
.msg-actions .act-report { color: #d4574e; border-color: #f0b8b4; }
.msg-actions .act-report:hover { background: #fdeeed; }

/* 消息头像：左键查看资料 / 右键艾特 */
.msg-row > .avatar { font-size: 34px; line-height: 1; cursor: pointer; user-select: none; }
/* 图片头像：在线列表与消息行通用，圆形 */
.avatar-img {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  cursor: pointer; flex-shrink: 0; border: 1px solid var(--line-strong);
}
.online-item .avatar-img { width: 24px; height: 24px; }

/* ===== 输入区 ===== */
.input-area {
  position: relative; flex-shrink: 0; padding: 10px var(--s-4) 12px;  /* relative：作为遮罩/emoji面板的定位基准 */
  background: transparent;
  border-top: 1px solid var(--line);
}
/* 单行输入栏：工具按钮 | 输入框（自适应增高，最多3行） | 发送按钮 */
.input-tools { display: flex; gap: 2px; align-self: flex-end; padding-bottom: 6px; }
.input-tools button {
  border: none; background: none; font-size: 18px; cursor: pointer;
  width: 30px; height: 28px; border-radius: var(--r-xs); line-height: 28px;
}
.input-tools button:hover { background: var(--sea-50); }
.input-row { display: flex; gap: var(--s-2); align-items: flex-end; }
.input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--line-strong); border-radius: 10px;
  min-height: 38px; max-height: 96px; overflow-y: auto;
  padding: 8px 12px; font-size: 14px; font-family: inherit; line-height: 1.5; outline: none;
  background: #fff; color: var(--text);
}
.input-row textarea::placeholder { color: var(--ink-300); }
.input-row textarea:focus { border-color: var(--accent); }
.send-btn {
  border: none; background: linear-gradient(135deg, var(--sea-500), var(--sea-700)); color: #fff;
  font-weight: 600; padding: 9px 18px; border-radius: 10px; cursor: pointer; font-size: 14px;
  box-shadow: 0 4px 14px oklch(0.455 0.072 183 / 0.3); flex-shrink: 0;
}
.send-btn:disabled { background: var(--sea-200); color: var(--ink-300); box-shadow: none; cursor: not-allowed; }
.hint { font-size: 11px; color: var(--text-faint); margin-top: 5px; }

/* emoji 面板（纯白浮层） */
.chat-root .emoji-panel {
  position: absolute; bottom: 100%; left: var(--s-4); margin-bottom: var(--s-2);
  width: 340px; max-height: 260px; overflow-y: auto;
  border-radius: var(--r-md); padding: 10px; z-index: 20;
  background: #fff; border: 1px solid var(--line-strong);
  box-shadow: var(--sh-3);
}
.emoji-panel .cat { font-size: 12px; color: var(--text-faint); margin: 6px 0 4px; }
.emoji-panel .grid { display: grid; grid-template-columns: repeat(8, 1fr); }
.emoji-panel .grid button {
  border: none; background: none; font-size: 20px; cursor: pointer; padding: 4px 0; border-radius: 6px;
}
.emoji-panel .grid button:hover { background: var(--sea-50); }

/* @ 下拉 */
.chat-root .at-pop {
  position: absolute; bottom: 100%; left: 60px; margin-bottom: var(--s-2);
  width: 220px; max-height: 220px; overflow-y: auto;
  border-radius: var(--r-md); z-index: 20;
  background: #fff; border: 1px solid var(--line-strong);
  box-shadow: var(--sh-3);
}
.at-pop .item {
  display: flex; align-items: center; gap: var(--s-2); padding: 7px 12px;
  cursor: pointer; font-size: 13px; color: var(--text);
}
.at-pop .item:hover, .at-pop .item.active { background: var(--accent-soft); }
.at-pop .avatar-emoji { font-size: 18px; }

/* 引用草稿条 */
.quote-draft {
  display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2);
  background: var(--sea-50); border-left: 3px solid var(--accent);
  padding: 5px 10px; border-radius: 4px; font-size: 12px; color: var(--text-sub);
}
.quote-draft .x { margin-left: auto; cursor: pointer; color: var(--text-faint); font-size: 14px; }
.quote-draft .x:hover { color: var(--danger); }

/* 灯箱 */
.lightbox {
  position: fixed !important; inset: 0 !important; background: oklch(0.245 0.03 200 / 0.78); z-index: 99;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--r-sm); }

/* toast：深底反白，屏幕正中弹出（临时提示，刻意与浅色页面形成对比） */
.toast {
  position: fixed !important; top: 50% !important; left: 50% !important;
  transform: translate(-50%, -50%) !important;
  background: var(--ink-900); color: #fff; font-size: 13px;
  padding: 8px 18px; border-radius: 10px; z-index: 100;
  box-shadow: var(--sh-3);
  animation: fadein 0.2s;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; } }

/* ===== 成员右键菜单 / 资料卡片 ===== */
.ctx-mask { position: fixed; inset: 0; z-index: 40; }
.chat-root .ctx-menu {
  position: fixed; z-index: 41; min-width: 124px; padding: 6px; border-radius: 10px;
  display: flex; flex-direction: column; gap: 2px;
  background: #fff; border: 1px solid var(--line-strong);
  box-shadow: var(--sh-3);
}
.ctx-menu button {
  border: none; background: none; cursor: pointer; text-align: left;
  font-size: 13px; color: var(--text); padding: 7px 12px; border-radius: 7px;
}
.ctx-menu button:hover { background: var(--sea-50); color: var(--accent); }

.profile-mask {
  position: fixed; inset: 0; z-index: 50; background: oklch(0.245 0.03 200 / 0.35);
  display: flex; align-items: center; justify-content: center;
}
.chat-root .profile-card {
  width: 260px; border-radius: var(--r-lg); padding: 22px 20px 18px; text-align: center;
  background: #fff; border: 1px solid var(--line-strong);
  box-shadow: var(--sh-4); color: var(--text);
}
.p-emoji { font-size: 52px; line-height: 1.15; }
.p-name {
  margin-top: 10px; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.p-actions { margin-top: var(--s-4); display: flex; gap: var(--s-2); justify-content: center; }
.p-actions .p-close {
  border: 1px solid var(--line-strong); background: none; color: var(--text-sub);
  cursor: pointer; padding: 7px 16px; border-radius: 10px; font-size: 13px;
}
.p-actions .p-close:hover { color: var(--text); border-color: var(--ink-300); }

/* 举报弹窗 */
.chat-root .report-card {
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  width: min(400px, calc(100vw - 48px)); padding: 20px 22px;
  box-shadow: var(--sh-4);
  color: var(--text); font-size: 13px;
}
.rp-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.rp-quote {
  background: var(--sea-50); border-left: 3px solid var(--accent); border-radius: var(--r-xs);
  padding: 8px 12px; margin-bottom: 14px; color: var(--text-sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rp-label { color: var(--text-sub); margin-bottom: var(--s-2); }
.rp-reasons { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: 12px; }
.rp-reasons button {
  background: var(--sea-50); border: 1px solid var(--line); color: var(--text-sub);
  padding: 6px 14px; border-radius: var(--r-full); cursor: pointer; font-size: 12px;
}
.rp-reasons button:hover { color: var(--text); border-color: var(--line-strong); }
.rp-reasons button.active {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600;
}
.rp-detail {
  width: 100%; box-sizing: border-box; min-height: 64px; resize: vertical;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px;
  color: var(--text); padding: 9px 12px; font-size: 13px; font-family: inherit;
}
.rp-detail::placeholder { color: var(--ink-300); }
.rp-detail:focus { outline: none; border-color: var(--accent); }
.rp-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.rp-actions button { padding: 8px 18px; border-radius: 10px; cursor: pointer; font-size: 13px; border: none; }
.rp-cancel { background: none; border: 1px solid var(--line-strong) !important; color: var(--text-sub); }
.rp-cancel:hover { color: var(--text); }
.rp-submit { background: linear-gradient(135deg, var(--sea-500), var(--sea-700)); color: #fff; font-weight: 600; }
.rp-submit:disabled { opacity: 0.45; cursor: not-allowed; }

/* 滚动条 */
.chat-root ::-webkit-scrollbar { width: 6px; }
.chat-root ::-webkit-scrollbar-thumb { background: oklch(0.38 0.032 200 / 0.25); border-radius: 3px; }
.chat-root ::-webkit-scrollbar-thumb:hover { background: oklch(0.38 0.032 200 / 0.4); }
.chat-root ::-webkit-scrollbar-track { background: transparent; }

/* 侧栏/聊天列裁剪圆角内容 */
.chat-root .sidebar, .chat-root .chat-col { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .notice-scroll { animation: none; }
  .msg-actions { transition: none; }
}
