/* app.css — 笔友代写工作台覆盖样式
 *
 * 基础：Gentelella v4 编译后 main-v4-*.css（本地文件，不依赖 CDN）
 * 本文件只写 Gentelella 没有或需要改写的部分：
 * - 顶部横向导航（56px，替代 Gentelella 的左侧 sidebar）
 * - 主工作台三栏 260 / 1fr / 340（项目书 §6.1 写死）
 * - 状态 chip 固定色系（项目书 §9）
 * - 通信气泡、助手面板、草稿编辑框
 *
 * 颜色优先引用 Gentelella 的 CSS 变量；变量名不确定处用 fallback。
 */

/* ---------------------------------------------------------------- 基础 */
* { box-sizing: border-box; }

/* 手机专用控件默认隐藏。
   必须放在文件最前面：本文件后面的 @media 块里会把它们改成 display:flex/block，
   若隐藏规则排在那些 @media 之后，同等特异性下会反过来盖掉，导致手机上永远不显示。 */
.m-backbar,
.m-assist-btn,
.m-list-title { display: none; }

/* 顶部导航：两行结构
   第一行 .brandbar  站名 + 右上角状态
   第二行 .navrow    一级分组 + 二级标签（同一行）
   总高 = --pnav-h（实测 88px），由 .main 与三栏自动扣减 */
:root {
  --pnav-h: 88px;
  --brandbar-h: 44px;
}

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font, "Inter", -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text, #1f2937);
  background: var(--bg-surface-secondary, #f5f7fa);
}

a { color: var(--primary, #1abb9c); text-decoration: none; }
a:hover { text-decoration: underline; }

pre, code, textarea { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.mt-3 { margin-top: 16px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.p-0 { padding: 0 !important; }

/* ---------------------------------------------------------------- 顶部导航 */
.pnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg-surface, #fff);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

/* 第一行：站名 + 右上角状态 */
.brandbar {
  height: var(--brandbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color-soft, #f1f3f5);
}
.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--text, #111);
}
.brandbar-right { display: flex; align-items: center; gap: 8px; }
.logout-form { margin: 0; display: flex; }

/* 第二行：一级分组 + 二级标签 */
.navrow {
  height: calc(var(--pnav-h) - var(--brandbar-h));
  display: flex;
  align-items: stretch;
  gap: 16px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.navrow::-webkit-scrollbar { display: none; }

.pnav-links { display: flex; align-items: stretch; gap: 2px; flex-shrink: 0; }
.pnav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text-secondary, #6b7280);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.pnav-link:hover { color: var(--text, #111); text-decoration: none; }
.pnav-link.active {
  color: var(--primary, #1abb9c);
  border-bottom-color: var(--primary, #1abb9c);
  font-weight: 500;
}

.nav-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger, #e74c3c);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  font-weight: 500;
}

/* 二级标签：接在一级后面，同一条线上 */
.subnav-inline {
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border-color, #e5e7eb);
  flex-shrink: 0;
}
.subnav-tab {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.subnav-tab:hover { color: var(--text, #111); text-decoration: none; }
.subnav-tab.active {
  color: var(--primary, #1abb9c);
  border-bottom-color: var(--primary, #1abb9c);
  font-weight: 500;
}

.pnav-contact {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text);
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--primary-lt, #e8f8f4);
}
.pnav-contact.pnav-empty { background: transparent; color: var(--text-muted, #9ca3af); }

/* ---------------------------------------------------------------- 内容区 */
.main {
  padding-top: var(--pnav-h);
  min-height: 100vh;
}

.page-wrapper { padding: 20px 24px; }
.page-wrapper.wrap-wide { padding: 20px 24px 32px; }
/* 主工作台：去掉内边距，三栏铺满视口 */
.page-wrapper.wb-wrap { padding: 0; max-width: none; }

.page-header { margin-bottom: 16px; }
/* 页眉操作按钮靠左挨着标题：space-between 会把按钮甩到最右、中间大片空白（用户反馈 2026-11-04） */
.page-header-row { display: flex; align-items: flex-end; justify-content: flex-start; gap: 16px; }
.page-pretitle {
  font-size: 11px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-muted, #9ca3af);
}
.page-title { margin: 2px 0 0; font-size: 21px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- 主工作台三栏（写死 260/1fr/340） */
/* 断点只调这三条栏宽，布局结构与写死值保持一致；窄屏见文末 @media */
.wb-grid {
  display: grid;
  grid-template-columns: var(--wb-left-w, 260px) minmax(0, 1fr) var(--wb-right-w, 340px);
  height: calc(100vh - var(--pnav-h));
  overflow: hidden;
}

.wb-left {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color-light, #eef0f3);
  background: var(--bg-surface, #fff);
  overflow: hidden;
}

.wb-left-top {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border-color-light, #eef0f3);
}

.wb-left .inbox-search,
.wb-left-top .inbox-search {
  /* Gentelella 的 .inbox-search 带 flex:1 / height:28px 且特异度高于单类，
     这里用 .wb-left 前缀提升特异度，确保输入框撑满 260px 栏宽 */
  flex: 0 0 auto;
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  background: var(--bg-surface-secondary, #f5f7fa);
  color: var(--text);
}
.inbox-search:focus {
  outline: none;
  border-color: var(--primary, #1abb9c);
  background: var(--bg-surface, #fff);
}

/* 筛选 tab（写死四个） */
.ftabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

.ftab {
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 12px;
  color: var(--text-secondary, #6b7280);
  background: var(--bg-surface-secondary, #f5f7fa);
}
.ftab:hover { text-decoration: none; color: var(--text); }
.ftab.active { background: var(--primary, #1abb9c); color: #fff; }

/* 笔友列表 */
.pt-list { flex: 1; overflow-y: auto; }

.pt-wrap { position: relative; }
.pt-ops {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 80ms;
}
.pt-wrap:hover .pt-ops, .pt-wrap:focus-within .pt-ops { opacity: 1; }
@media (hover: none) { .pt-ops { opacity: 1; } }
.pt-op {
  font-size: 11px;
  line-height: 1;
  padding: 4px 7px;
  border: 1px solid var(--border-color-light, #e3e6eb);
  border-radius: 6px;
  background: var(--bg-surface, #fff);
  color: var(--text-secondary, #666);
  cursor: pointer;
}
.pt-op:hover { color: var(--text, #111); border-color: var(--primary, #1abb9c); }

.pt-item {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color-light, #eef0f3);
  color: inherit;
  transition: background 80ms;
}
.pt-item:hover { background: var(--bg-surface-secondary, #f5f7fa); text-decoration: none; }
.pt-item.selected {
  background: var(--primary-lt, #e8f8f4);
  border-left: 2px solid var(--primary, #1abb9c);
  padding-left: 10px;
}

.pt-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #111);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted, #9ca3af);
  margin-top: 2px;
}

.pt-count {
  min-width: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: #d97706;
  color: #fff;
  font-size: 10.5px;
  text-align: center;
}

.pt-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }

.wb-left-foot {
  padding: 8px 10px;
  border-top: 1px solid var(--border-color-light, #eef0f3);
}
.wb-foot-stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary, #666);
  margin-bottom: 8px;
}
.wb-foot-stats a { color: inherit; }
.wb-foot-stats b { color: var(--text, #111); }

/* 设置页：左侧分类导航 + 右侧分组卡片（锚点跳转） */
.settings-layout { display: flex; gap: 16px; align-items: flex-start; }
.settings-nav {
  position: sticky;
  top: calc(var(--pnav-h, 96px) + 12px);
  flex: 0 0 132px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav a {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary, #555);
}
.settings-nav a:hover { background: var(--bg-surface-secondary, #f5f7fa); text-decoration: none; color: var(--text, #111); }
.settings-main { flex: 1; min-width: 0; }
.settings-main .card { scroll-margin-top: calc(var(--pnav-h, 96px) + 12px); }
.settings-main [id] { scroll-margin-top: calc(var(--pnav-h, 96px) + 12px); }
@media (max-width: 760px) {
  .settings-layout { flex-direction: column; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; flex-basis: auto; }
}

/* 批量破冰 */
.ob-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ob-sub { font-size: 12px; color: var(--text-secondary, #888); margin-top: 2px; }
.ob-err { font-size: 12px; color: #c0392b; margin-top: 2px; }
.ob-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.ob-add { border-bottom: 1px solid var(--border-color-light, #eef0f3); padding-bottom: 12px; margin-bottom: 6px; }
.ob-bulk { margin-top: 10px; }
.ob-bulk summary, .ob-detail summary { cursor: pointer; font-size: 12.5px; color: var(--text-secondary, #555); }
.ob-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 8px 0; }
@media (max-width: 760px) { .ob-compare { grid-template-columns: 1fr; } }
.ob-col-title { font-weight: 600; font-size: 12.5px; margin-bottom: 6px; }
.ob-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 300px;
  overflow: auto;
  margin: 0;
}
.ob-shot { max-width: 100%; border-radius: 8px; margin-bottom: 8px; }
.persona-pre { max-height: 260px; }

/* 中栏 */
.wb-mid {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-surface-secondary, #f5f7fa);
}

.statbar {
  display: flex;
  gap: 20px;
  padding: 9px 16px;
  font-size: 12.5px;
  color: var(--text-secondary, #6b7280);
  background: var(--bg-surface, #fff);
  border-bottom: 1px solid var(--border-color-light, #eef0f3);
}
.statbar b { color: var(--text, #111); font-weight: 600; }

.wb-mid-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--bg-surface, #fff);
  border-bottom: 1px solid var(--border-color-light, #eef0f3);
}
.wb-mid-toolbar .ftabs { margin-top: 0; margin-left: auto; }

.stream { flex: 1; overflow-y: auto; padding: 16px; }

/* ---------------------------------------------------------------- 通信气泡 */
.bubble {
  max-width: 78%;
  margin-bottom: 12px;
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-color-light, #eef0f3);
}
.bubble-in { margin-right: auto; }
.bubble-out {
  margin-left: auto;
  background: var(--primary-lt, #e8f8f4);
  border-color: transparent;
}

/* 可选中：点击气泡把该封邮件载入右栏 */
.bubble { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.bubble:hover {
  border-color: var(--primary, #1abb9c);
  box-shadow: 0 1px 6px rgba(26, 187, 156, .18);
}
.bubble:focus-visible {
  outline: 2px solid var(--primary, #1abb9c);
  outline-offset: 1px;
}
/* 当前选中的那封 */
.bubble-active {
  border-color: var(--primary, #1abb9c);
  box-shadow: 0 0 0 2px var(--primary-lt, #e8f8f4);
}

/* 待审邮件的「在右侧处理」提示 */
.bubble-actions-hint {
  margin-top: 6px;
  font-size: 11.5px;
}
.bubble-act-open {
  color: var(--primary, #1abb9c);
  border-bottom: 1px dashed currentColor;
}

/* 右栏邮件详情面板 */
.wb-right.as-detail .as-verdict { display: flex; gap: 6px; align-items: center; }

.bubble-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted, #9ca3af);
}
.bubble-who { font-weight: 600; color: var(--text, #111); font-size: 12.5px; }

.bubble-subject {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text, #111);
}

.bubble-detail { margin-top: 6px; }
.bubble-detail > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--primary, #1abb9c);
  list-style: none;
}
.bubble-detail > summary::-webkit-details-marker { display: none; }
.bubble-detail > summary::before { content: "\25B8 "; }
.bubble-detail[open] > summary::before { content: "\25BE "; }

.bubble-body {
  margin: 8px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-surface-secondary, #f5f7fa);
  border-radius: 6px;
}

.bubble-meta { margin-top: 8px; font-size: 11.5px; }

/* 正文缺失时的占位提示 */
.bubble-body-empty {
  color: var(--text-muted, #9ca3af);
  font-style: normal;
  background: #fffbeb;
  border: 1px dashed #fcd34d;
}
.bubble-meta-row { display: flex; gap: 8px; padding: 1px 0; }
.bubble-meta-row .k { color: var(--text-muted, #9ca3af); flex-shrink: 0; min-width: 66px; }
.bubble-meta-row .v { color: var(--text-secondary, #6b7280); word-break: break-all; }

/* ---------------------------------------------------------------- 草稿编辑 */
.edit-wrap { flex: 1; display: flex; min-height: 0; overflow: hidden; }

.edit-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 0;
  min-width: 0;
}

.edit-subject { font-size: 13px; font-weight: 500; margin-bottom: 8px; color: var(--text, #111); }

.edit-area {
  flex: 1;
  width: 100%;
  min-height: 240px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text, #111);
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  resize: none;
}
.edit-area:focus { outline: none; border-color: var(--primary, #1abb9c); }

.edit-hints { padding: 6px 0 10px; font-size: 12px; color: #d97706; }

.edit-foot {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-surface, #fff);
  border-top: 1px solid var(--border-color-light, #eef0f3);
}

.edit-foot-secondary {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  background: var(--bg-surface, #fff);
}

/* ---------------------------------------------------------------- 回复节奏 */
/* 草稿编辑页：计划发送时间条 */
.schedule-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-color-light, #eef0f3);
}
.schedule-bar.due-later { background: #eff6ff; color: #1e40af; }
.schedule-bar.due-now { background: #ecfdf5; color: #065f46; }
.schedule-icon { font-size: 13px; }
.schedule-wait {
  margin-left: auto;
  font-weight: 600;
  white-space: nowrap;
}

/* 设置页：当前节奏一句话摘要 */
.cadence-summary {
  margin-bottom: 14px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #065f46;
  background: #ecfdf5;
  border-left: 3px solid #10b981;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- 右侧助手 */
.wb-right {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-surface, #fff);
  border-left: 1px solid var(--border-color-light, #eef0f3);
}

.as-head { padding: 12px 14px; border-bottom: 1px solid var(--border-color-light, #eef0f3); }

.as-title {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.as-verdict { margin-top: 6px; font-size: 12.5px; color: var(--text-secondary, #6b7280); }

.as-actions { display: flex; gap: 6px; margin-top: 9px; }

.as-sec { border-bottom: 1px solid var(--border-color-light, #eef0f3); }

.as-sec > summary,
.as-sec-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text, #111);
  cursor: pointer;
  list-style: none;
}
.as-sec > summary::-webkit-details-marker { display: none; }
.as-sec > summary::before { content: "\25B8"; color: var(--text-muted, #9ca3af); font-size: 10px; }
.as-sec[open] > summary::before { content: "\25BE"; }
.as-sec-fixed .as-sec-title { cursor: default; }

.as-count {
  margin-left: auto;
  min-width: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bg-surface-secondary, #f5f7fa);
  color: var(--text-muted, #9ca3af);
  font-size: 10.5px;
  font-weight: 500;
  text-align: center;
}

.as-sec-body { padding: 0 14px 10px; }

.as-item { padding: 8px 0; border-top: 1px dashed var(--border-color-light, #eef0f3); }
.as-item:first-child { border-top: none; padding-top: 0; }

.as-sentence {
  font-size: 12.5px;
  color: var(--text, #111);
  background: #fff7e6;
  padding: 3px 6px;
  border-radius: 4px;
  word-break: break-word;
}

.as-kind { margin-top: 4px; font-size: 11px; color: var(--text-muted, #9ca3af); }

.as-fix {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--primary, #1abb9c);
  word-break: break-word;
}

.as-item-actions { display: flex; gap: 5px; margin-top: 6px; }

.as-empty { font-size: 12.5px; color: var(--text-muted, #9ca3af); padding: 2px 0; }
.as-note { font-size: 12.5px; color: var(--text-secondary, #6b7280); padding: 3px 0; }

/* ---------------------------------------------------------------- 状态 chip（固定色系 §9） */
.chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  line-height: 17px;
  white-space: nowrap;
}

.chip-warn { background: #fef3c7; color: #92400e; }   /* 待审 黄 */
.chip-ok { background: #d1fae5; color: #065f46; }     /* 已发 绿 */
.chip-err { background: #fee2e2; color: #991b1b; }    /* 失败 红 */
.chip-stranger { background: #e5e7eb; color: #374151; } /* 陌生人 灰 */
.chip-conflict { background: #ffedd5; color: #9a3412; } /* 冲突 橙 */
.chip-info { background: #dbeafe; color: #1e40af; }
.chip-muted { background: var(--bg-surface-secondary, #f5f7fa); color: var(--text-muted, #9ca3af); }

/* ---------------------------------------------------------------- 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color-light, #eef0f3);
  vertical-align: top;
}
.tbl th {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted, #9ca3af);
  background: var(--bg-surface-secondary, #f5f7fa);
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--bg-surface-secondary, #f5f7fa); }

.td-actions { white-space: nowrap; }
.td-actions .btn { margin-right: 3px; }
.td-advice { font-size: 12px; color: var(--text-secondary, #6b7280); max-width: 240px; }
.td-err { font-size: 12px; color: #991b1b; max-width: 260px; word-break: break-word; }
.tr-detail td { padding: 0 !important; }

.log-detail { padding: 6px 12px 10px; }
.log-detail > summary { cursor: pointer; font-size: 12px; color: var(--primary, #1abb9c); }
.log-detail pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-surface-secondary, #f5f7fa);
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
}

/* ---------------------------------------------------------------- 折叠分区（记忆/状态） */
.memory-sec, .status-sec { margin-bottom: 10px; }
.memory-sec > summary,
.status-sec > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.memory-sec > summary::-webkit-details-marker,
.status-sec > summary::-webkit-details-marker { display: none; }
.memory-sec > summary::before,
.status-sec > summary::before {
  content: "\25B8";
  font-size: 10px;
  color: var(--text-muted, #9ca3af);
}
.memory-sec[open] > summary::before,
.status-sec[open] > summary::before { content: "\25BE"; }

.mem-item { padding: 9px 0; border-bottom: 1px dashed var(--border-color-light, #eef0f3); }
.mem-item:last-child { border-bottom: none; }

.mem-text { font-size: 13px; word-break: break-word; }
.mem-meta { margin-top: 4px; font-size: 11px; color: var(--text-muted, #9ca3af); }
.mem-mid { margin-left: 6px; font-family: Consolas, monospace; }
.mem-ops { display: flex; gap: 5px; margin-top: 6px; }

/* ---------------------------------------------------------------- 表单 */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text, #111);
}

.form-control {
  width: 100%;
  max-width: 420px;
  height: 34px;
  padding: 0 10px;
  font-size: 13.5px;
  color: var(--text, #111);
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
}
.form-control:focus { outline: none; border-color: var(--primary, #1abb9c); }

select.form-control { max-width: 320px; cursor: pointer; }

.input-row { display: flex; align-items: center; gap: 8px; }
.input-row .form-control { width: 140px; max-width: 140px; }
.unit { font-size: 12.5px; color: var(--text-muted, #9ca3af); }

.field-impact { margin-top: 4px; font-size: 12px; color: var(--text-muted, #9ca3af); max-width: 520px; }

/* 开关 */
.form-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.form-switch input { position: absolute; opacity: 0; pointer-events: none; }
.form-switch span {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #d1d5db;
  transition: background .15s;
}
.form-switch span::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
}
.form-switch input:checked + span { background: var(--primary, #1abb9c); }
.form-switch input:checked + span::after { transform: translateX(16px); }

/* ---------------------------------------------------------------- 卡片 / 横幅 / 空状态 */
.card {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-color-light, #eef0f3);
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text, #111);
  border-bottom: 1px solid var(--border-color-light, #eef0f3);
  background: var(--bg-surface-secondary, #f5f7fa);
}

.card-body { padding: 14px; }

/* 陌生人详情操作条 */
.unknown-ops { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 弹窗
   基础样式（backdrop/dialog/header/body/footer 等）用主题 CSS 自带的 .modal-*，
   不再手写重复定义；下面只有本项目专属的 .modal-radio（trust 二选一卡片）。 */

/* trust 二选一：单选卡片 */
.modal-radio {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color-light, #eef0f3);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.modal-radio:hover { border-color: var(--primary, #1abb9c); background: var(--primary-lt, #e8f8f4); }
.modal-radio input { margin-top: 3px; flex-shrink: 0; accent-color: var(--primary, #1abb9c); }
.modal-radio b { display: block; font-size: 13.5px; font-weight: 500; color: var(--text, #111); }
.modal-radio em {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-style: normal;
  color: var(--text-muted, #9ca3af);
}


/* 新建草稿：来信选择列表 */
.pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color-light, #eef0f3);
  border-radius: 8px;
  transition: border-color .12s, background .12s;
}
.pick-row:hover { border-color: var(--primary, #1abb9c); background: var(--primary-lt, #e8f8f4); }
.pick-main { min-width: 0; }
.pick-subject {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text, #111);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-muted, #9ca3af);
}
.pick-act { flex-shrink: 0; }

.banner { display: flex; gap: 8px; padding: 9px 16px; font-size: 13px; }
.banner-danger { background: #fee2e2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.banner-body { display: flex; align-items: center; gap: 8px; }
.banner-icon {
  flex-shrink: 0;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #991b1b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.empty-state { padding: 40px 20px; text-align: center; }
.empty-state-icon { font-size: 26px; color: #d1d5db; line-height: 1; margin-bottom: 8px; }
.empty-state-title { font-size: 14px; font-weight: 600; color: var(--text-secondary, #6b7280); }
.empty-state-text { margin: 4px 0 12px; font-size: 12.5px; color: var(--text-muted, #9ca3af); }

/* 代码块 / diff / 日志 */
.codeblock {
  margin: 0;
  padding: 12px;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-surface-secondary, #f5f7fa);
  border-radius: 6px;
  max-height: 420px;
  overflow-y: auto;
}

.diff {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
}

.logtail {
  margin: 0;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-surface-secondary, #f5f7fa);
  border-radius: 6px;
  max-height: 320px;
  overflow-y: auto;
}

/* ---------------------------------------------------------------- 登录页 */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-surface-secondary, #f5f7fa);
}

.login-card {
  width: 340px;
  padding: 28px 26px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-color-light, #eef0f3);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.login-card h1 { margin: 0 0 18px; font-size: 18px; font-weight: 600; }
.login-card .form-control { max-width: none; }
.login-card .btn { width: 100%; }

/* ---------------------------------------------------------------- 按钮补充 */
.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 11.5px;
  line-height: 22px;
  border-radius: 5px;
}

.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* 提示条：说明性文字，不占焦点 */
.hint-bar {
  margin-bottom: 14px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.65;
  color: #065f46;
  background: #ecfdf5;
  border-left: 3px solid #10b981;
  border-radius: 4px;
}
.hint-bar b { font-weight: 600; }

/* ---------------------------------------------------------------- 邮箱账号卡片 */
.mb-list { display: flex; flex-direction: column; gap: 10px; }

.mb-card {
  padding: 14px 16px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-color-light, #eef0f3);
  border-radius: 8px;
}

.mb-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mb-label { font-size: 14.5px; font-weight: 600; color: var(--text, #111); }
.mb-email { margin-top: 2px; font-size: 12.5px; color: var(--text-muted, #9ca3af); }
.mb-tags { display: flex; flex-wrap: wrap; gap: 4px; flex-shrink: 0; }

.mb-servers {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
}

.mb-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mb-grid {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

/* 表单里的复选框 */
.form-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
}
.form-check input { accent-color: var(--primary, #1abb9c); width: 16px; height: 16px; }

@media (max-width: 768px) {
  .mb-grid { grid-template-columns: 1fr; }
  .mb-head { flex-direction: column; }
}

/* ---------------------------------------------------------------- 滚动条 */
.pt-list::-webkit-scrollbar,
.stream::-webkit-scrollbar,
.wb-right::-webkit-scrollbar,
.codeblock::-webkit-scrollbar,
.logtail::-webkit-scrollbar,
.log-detail pre::-webkit-scrollbar { width: 8px; }

.pt-list::-webkit-scrollbar-thumb,
.stream::-webkit-scrollbar-thumb,
.wb-right::-webkit-scrollbar-thumb,
.codeblock::-webkit-scrollbar-thumb,
.logtail::-webkit-scrollbar-thumb,
.log-detail pre::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ================================================================
 * 响应式：平板保留三栏，手机改单栏
 * ----------------------------------------------------------------
 * 断点与行为：
 *   > 1400px     桌面：三栏 260 / 自适应 / 340（写死值，不变）
 *   1024–1400px  平板横屏/桌面窄屏：收窄左右栏，保中栏可读
 *    768–1024px  平板竖屏（iPad 1024 落在区间上沿）：进一步收窄
 *   <= 768px     手机：三栏退化为「列表 → 详情」单栏，底部返回
 * ---------------------------------------------------------------- */

/* ---- 平板横屏 / 窄桌面：收窄左右栏 ---- */
@media (max-width: 1400px) {
  .wb-grid {
    --wb-left-w: 230px;
    --wb-right-w: 300px;
  }
}

/* ---- 平板竖屏（iPad 1024）：继续收窄，保证中栏 >= 400px ---- */
@media (max-width: 1100px) {
  .wb-grid {
    --wb-left-w: 200px;
    --wb-right-w: 280px;
  }
  .page-wrapper,
  .page-wrapper.wrap-wide { padding: 14px 16px; }
  .page-wrapper.wb-wrap { padding: 0; }
  .bubble { max-width: 88%; }
}

/* ---- 窄平板竖屏（768–1080）----
   三栏在这个宽度下会把中栏挤到 300px 以下，阅读体验差。
   直接并成两栏：左列表 + 中栏；右栏助手改为侧滑抽屉（复用 .m-drawer 机制）。 */
@media (max-width: 1080px) and (min-width: 769px) {
  .wb-grid {
    --wb-left-w: 220px;
    grid-template-columns: var(--wb-left-w) minmax(0, 1fr);
  }
  .wb-right { display: none; }
  .m-assist-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    bottom: 12px;
    margin: 0 12px 12px auto;
    width: fit-content;
    padding: 9px 16px;
    font-size: 13.5px;
    color: #fff;
    background: var(--primary, #1abb9c);
    border: none;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(26, 187, 156, .35);
    cursor: pointer;
  }
  .wb-right.m-open {
    display: flex;
    position: fixed;
    right: 0;
    bottom: 0;
    left: auto;
    top: 12vh;
    width: 340px;
    z-index: 910;
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 24px rgba(15, 23, 42, .18);
  }
}

/* ---- 手机：单栏，列表与详情互斥 ---- */
@media (max-width: 768px) {
  body { font-size: 15px; }

  /* 顶部导航：品牌缩略，标签横向滑动，右侧只留刷新 */
  .pnav { padding: 0 10px; gap: 8px; }
  .pnav-left { gap: 10px; flex: 1; min-width: 0; }
  .pnav-brand { font-size: 14px; }
  .pnav-links {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pnav-links::-webkit-scrollbar { display: none; }
  .pnav-link { padding: 0 10px; font-size: 13px; }
  .pnav-right { gap: 6px; }
  .pnav-contact { display: none; }
  .pnav-right .btn { padding: 0 8px; font-size: 12px; }

  /* 三栏 -> 单栏：默认只显示列表 */
  .wb-grid {
    --wb-left-w: 100%;
    --wb-right-w: 100%;
    grid-template-columns: 100%;
    grid-template-rows: auto;
    height: calc(100vh - var(--pnav-h));
    position: relative;
  }
  .wb-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color-light, #eef0f3);
  }
  .wb-mid,
  .wb-right { display: none; width: 100%; }

  /* 选中笔友后：隐藏列表，显示中栏 */
  .wb-grid.m-show-mid .wb-left { display: none; }
  .wb-grid.m-show-mid .wb-mid { display: flex; }

  /* 打开草稿编辑：隐藏助手面板，编辑区占满（助手可在抽屉里看） */
  .wb-grid.m-show-mid.m-editing .wb-right { display: none; }

  /* 底部返回条：单栏时才有，用于从详情回列表 */
  .m-backbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-surface, #fff);
    border-bottom: 1px solid var(--border-color-light, #eef0f3);
    font-size: 13.5px;
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .m-backbar button {
    border: none;
    background: none;
    color: var(--primary, #1abb9c);
    font-size: 14px;
    padding: 2px 4px;
    cursor: pointer;
  }
  .m-backbar .m-back-title {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 助手面板开关（手机端从底部抽屉查看） */
  .m-assist-btn { display: inline-flex; }

  /* 表格横向滚动，不再挤成竖条 */
  .tbl-wrap, .card > .tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 560px; }

  /* 气泡占满宽度 */
  .bubble { max-width: 100%; }

  /* 页面内边距收紧 */
  .page-wrapper,
  .page-wrapper.wrap-wide { padding: 12px 12px 20px; }
  .page-title { font-size: 18px; }
  .page-header-row { flex-wrap: wrap; gap: 8px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  /* 表单控件全宽，方便点按 */
  .form-control, select.form-control { max-width: 100%; width: 100%; }
  .input-row .form-control { width: 100%; max-width: 100%; }

  /* 弹窗贴合屏幕 */
  .modal-dialog { width: calc(100vw - 24px); max-width: none; }

  /* 底部操作栏在手机上加安全区，避免被手势条挡住 */
  .edit-foot, .edit-foot-secondary {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .edit-foot { flex-wrap: wrap; }
  .edit-foot .btn { flex: 1; min-width: 72px; }

  /* 点按区域放大到 44px 可点击标准 */
  .btn-sm, .btn-xs { min-height: 34px; padding: 0 10px; }
}

@media (max-width: 768px) {
  /* 列表页标题 */
  .m-list-title {
    display: block;
    padding: 2px 2px 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text, #111);
  }

  /* 底部「编辑助手」按钮：浮在中栏右下角 */
  .m-assist-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    bottom: 12px;
    margin: 0 12px 12px auto;
    width: fit-content;
    padding: 9px 16px;
    font-size: 13.5px;
    color: #fff;
    background: var(--primary, #1abb9c);
    border: none;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(26, 187, 156, .35);
    cursor: pointer;
  }
  .m-assist-btn:active { transform: scale(.97); }
}

/* 手机端助手抽屉 */
.m-drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .38);
  z-index: 900;
}
.m-drawer-mask.show { display: block; }

@media (max-width: 768px) {
  .wb-right.m-open {
    display: flex;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    top: 20vh;
    z-index: 910;
    width: 100%;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -6px 24px rgba(15, 23, 42, .18);
  }
}

/* ---------------------------------------------------------------- 设置页：笔友技能 */
.skill-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.skill-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  background: var(--bg-surface-secondary, #f5f7fa);
  border-radius: 6px;
  font-size: 13px;
}
.skill-name {
  font-family: monospace;
  font-size: 12.5px;
  color: var(--primary, #1abb9c);
  flex-shrink: 0;
  min-width: 190px;
}
.skill-desc { color: var(--text-secondary, #4b5563); }

/* ---------------------------------------------------------------- 右栏标签页 */
.as-tabs {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  flex-shrink: 0;
}
.as-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--text-secondary, #6b7280);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.as-tab:hover { color: var(--text, #111); text-decoration: none; }
.as-tab.active {
  color: var(--primary, #1abb9c);
  border-bottom-color: var(--primary, #1abb9c);
  font-weight: 500;
}
.as-tab-panel { display: none; }
.as-tab-panel.active { display: block; }


/* 开发模式反馈悬浮按钮（服务端开启 dev_mode 时才注入页面） */
#pp-feedback-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1080;
  padding: 9px 18px;
  border: none;
  border-radius: 999px;
  background: #2a3f54;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
  cursor: pointer;
}
#pp-feedback-btn:hover { background: #1c2f42; }

/* 快速回信段落对照（左来信 / 右回信，一段对一段） */
.pair-row { display: flex; gap: 8px; margin-bottom: 8px; }
.pair-cell { flex: 1 1 0; padding: 8px 10px; border: 1px solid rgba(127, 127, 127, .35); border-radius: 6px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.pair-left { opacity: .78; background: rgba(127, 127, 127, .08); }
.pair-cell .btn { margin-top: 6px; }
@media (max-width: 640px) { .pair-row { flex-direction: column; } }
.pair-locked { border-color: #b58900 !important; background: rgba(181, 137, 0, .10); }

/* ---- 外语层（改版第 3 期）：译文段落对照、译出区、联系人地理行 ---- */
.tr-block { margin-top: 8px; }
.tr-title { font-size: 12px; opacity: .75; margin-bottom: 6px; }
.tr-pair { margin-bottom: 10px; }
.tr-orig { font-size: 13px; line-height: 1.55; opacity: .72; white-space: pre-wrap; word-break: break-word; }
.tr-zh { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.cell-sub { font-size: 12px; opacity: .7; margin-top: 2px; }
.edit-alt { margin-top: 14px; border-top: 1px dashed rgba(127, 127, 127, .4); padding-top: 10px; }
.edit-alt-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 14px; }
.edit-area-alt { min-height: 140px; width: 100%; }

/* ---- 手机端体验包（2026-11-03，用户反馈：手机上还是电脑版操作感） ---- */
html { -webkit-text-size-adjust: 100%; }
@media (max-width: 768px) {
  /* iOS 聚焦自动缩放的根源：输入框字号 <16px。抬到 16px，点哪个框都不再放大页面 */
  input.form-control, textarea.form-control, select.form-control, .edit-area { font-size: 16px !important; }
  /* 子导航单行横滑，不换行撑高顶栏 */
  .subnav-inline { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .subnav-inline::-webkit-scrollbar { display: none; }
  .subnav-tab { white-space: nowrap; padding: 8px 10px; }
  /* 顶栏切换行横滑提示：右缘渐隐，让人一眼知道还能往右滑（当前页标签由 JS 自动滚入视野） */
  .navrow { -webkit-mask-image: linear-gradient(to right, #000 93%, transparent); mask-image: linear-gradient(to right, #000 93%, transparent); }
  /* 导航与按钮的点按高度 */
  .pnav-link { min-height: 42px; display: inline-flex; align-items: center; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 38px; }
  /* 卡片内边距再收一点，给内容让宽 */
  .card-body { padding: 12px; }
  /* 操作按钮组：更好点，主按钮占满一行 */
  .mb-ops .btn { flex: 1 1 auto; }
  .mb-ops .btn-primary { flex: 1 1 100%; }
  /* 反馈悬浮按钮避开 iPhone 手势条 */
  #pp-feedback-btn { bottom: calc(14px + env(safe-area-inset-bottom)); right: 12px; padding: 8px 14px; }
  /* 草稿框在手机上别太矮 */
  .edit-area { min-height: 160px; }
}

/* ---------------------------------------------------------------- 收件人候选下拉（JS 补强，原生 datalist 在部分手机端不弹） */
.cpick-wrap { position: relative; }
.cpick-box {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 60;
  margin-top: 4px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .14);
  overflow: hidden;
}
.cpick-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-color-light, #f1f5f9);
  font-size: 14px;
  color: var(--text, #111);
  cursor: pointer;
}
.cpick-item:last-child { border-bottom: none; }
.cpick-item:active { background: var(--bg-surface-secondary, #f5f7fa); }

/* 多候选起稿（第三梯队） */
.cand-card { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.cand-head { font-weight: 600; margin-bottom: 4px; }
.cand-prev { color: #555; font-size: 13px; margin-bottom: 8px; white-space: pre-wrap; }
