/* 继承原项目（EMAIL MCP）设计语言 + 条件三栏（D-11②）：
   无详情 = 左栏侧栏 + 右栏列表；点邮件 = 列表收窄 + 第三栏详情滑出 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f6f8; --border: #e5e7eb; --indigo: #4f46e5;
  --red: #dc2626; --blue: #0ea5e9; --gray: #737373; --orange: #f59e0b;
  --unread-bg: #fefce8;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: #1f2937; line-height: 1.55;
}

/* ===== 工作区：左栏 + 列表 + （条件出现）详情 ===== */
.workspace { display: flex; height: 100vh; overflow: hidden; }

/* ===== 左栏侧栏（继承原设计） ===== */
.sidebar {
  width: 280px; flex-shrink: 0; background: white;
  border-right: 1px solid var(--border); height: 100vh;
  display: flex; flex-direction: column;
}
.sidebar-header { padding: 14px 16px; border-bottom: 1px solid #f3f4f6; }
.btn { font-family: inherit; cursor: pointer; border: none; border-radius: 6px; font-size: 13px; }
.btn-primary { background: var(--indigo); color: white; padding: 8px 14px; }
.btn-primary:hover { background: #4338ca; }
.sidebar-compose-btn { display: block; width: 100%; text-align: center; font-size: 14px; font-weight: 500; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-section { padding: 10px 12px; }
.sidebar-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: #9ca3af; letter-spacing: .5px; padding: 0 8px 8px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin-bottom: 2px; border-radius: 6px;
  text-decoration: none; color: #374151; font-size: 13px;
}
.sidebar-link:hover { background: #f9fafb; }
.sidebar-link.active { background: #eef2ff; color: var(--indigo); font-weight: 600; }
.badge {
  font-size: 11px; color: #9ca3af; padding: 1px 7px;
  background: #f3f4f6; border-radius: 999px; margin-left: auto;
}
.badge-warn { background: #fee2e2; color: #991b1b; }
.sidebar-footer { padding: 10px 12px; border-top: 1px solid #f3f4f6; display: flex; gap: 8px; }
.sidebar-footer-link { font-size: 12px; color: #4b5563; text-decoration: none; }
.sidebar-footer-link:hover { color: var(--indigo); }

/* ===== 中栏：邮件列表 ===== */
.list-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); transition: flex .18s ease; }
.list-head { padding: 14px 18px; border-bottom: 1px solid var(--border); background: #fff; }
.list-head h2 { font-size: 16px; }
.list-head h2 .count { color: #9ca3af; font-size: 13px; }
.search-input { width: 100%; margin-top: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; }
.email-list { flex: 1; overflow-y: auto; padding: 10px 12px; }
.email-row {
  background: #fff; padding: 10px 14px; margin-bottom: 4px; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer; transition: all .15s;
}
.email-row:hover { border-color: #c7d2fe; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.email-row.selected { border-color: var(--indigo); background: #eef2ff; }
.email-row.unread { background: var(--unread-bg); }
.row-meta { display: flex; gap: 12px; font-size: 11px; color: #9ca3af; margin-bottom: 3px; align-items: center; }
.row-meta .account { color: #6366f1; }
.row-meta .date { margin-left: auto; }
.row-subject { font-size: 14px; font-weight: 500; color: #1f2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-subject::before { content: "● "; color: transparent; font-size: 10px; }
.email-row.unread .row-subject::before { color: var(--red); }
.empty { padding: 16px; color: #9ca3af; font-style: italic; }

/* ===== 右栏：邮件详情（条件出现，D-11②） ===== */
.detail-pane { flex: 1; min-width: 0; display: none; flex-direction: column; background: #fff; border-left: 1px solid var(--border); overflow-y: auto; }
.workspace.has-detail .list-pane { flex: 0 0 400px; }
.workspace.has-detail .detail-pane { display: flex; }
.detail-head { padding: 16px 22px; border-bottom: 1px solid var(--border); background: #fff; position: sticky; top: 0; }
.detail-close { float: right; border: none; background: #f3f4f6; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; color: #6b7280; font-size: 13px; }
.detail-close:hover { background: #e5e7eb; }
.detail-actions { display: flex; gap: 6px; margin: 0 0 10px; flex-wrap: wrap; }
.detail-actions .btn { font-size: 12px; padding: 5px 10px; background: #f9fafb; border: 1px solid var(--border); }
.detail-actions .btn:hover { background: #eef2ff; border-color: var(--indigo); }
.detail-head h1 { font-size: 17px; margin-bottom: 6px; }
.detail-meta { font-size: 12px; color: #6b7280; }
.detail-body { padding: 18px 22px; white-space: pre-wrap; line-height: 1.7; font-size: 14px; }
.topnav { margin-bottom: 8px; }
.bucket-tag { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #eef2ff; color: #4338ca; }
.action-result { font-size: 12px; margin-top: 6px; min-height: 16px; }
.translate-box { margin: 10px 22px; padding: 12px 14px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; }
.translate-box pre { white-space: pre-wrap; font-family: inherit; font-size: 13px; }

/* 评语墙（对齐老系统 F14） */
.comments-box { padding: 0 22px 20px; }
.comments-title { font-size: 13px; font-weight: 600; margin: 6px 0 8px; }
.comment-item { background: #f9fafb; border-radius: 6px; padding: 8px 12px; margin-bottom: 6px; font-size: 13px; }
.comment-item b { color: #4338ca; font-size: 12px; }
.comment-time { color: #9ca3af; font-size: 11px; margin-left: 6px; }
.comment-add { display: flex; gap: 6px; margin-top: 8px; }
.comment-add input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.comment-add .btn { background: #f9fafb; border: 1px solid var(--border); }

/* 合并视图主题聚合（对齐老系统 F13） */
.topics-block { margin-bottom: 14px; }
.topics-title { font-size: 14px; font-weight: 600; padding: 8px 4px; }
.topic-group { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.topic-group summary { cursor: pointer; font-size: 14px; font-weight: 600; padding: 4px 2px; }
.topic-group .email-row { border: 1px solid #e2e8f0; }

/* 邮件行补充（对齐老系统 row-sub） */
.row-sub { font-size: 12px; color: #9ca3af; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flag { font-size: 12px; }
.sidebar-empty { padding: 8px; font-size: 12px; color: #9ca3af; font-style: italic; }
.sidebar-account-email { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #4b5563; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.attach-list { padding: 0 22px 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.attach-chip { font-size: 12px; padding: 4px 10px; background: #f9fafb; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.attach-chip:hover { background: #eef2ff; border-color: var(--indigo); }
.labels-bar { padding: 0 22px 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.email-label-chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: #f3f4f6; border: 1px solid #e5e7eb; }

/* 标签对话框 */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 100; }
.labels-dialog { width: 440px; max-width: 92vw; max-height: 80vh; overflow-y: auto; background: #fff; border-radius: 10px; padding: 20px; }
.labels-dialog h3 { margin-bottom: 12px; }
.label-group { margin-bottom: 12px; }
.label-group-name { font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.label-check { display: inline-flex; align-items: center; gap: 4px; margin: 0 12px 6px 0; font-size: 13px; }

/* ===== 独立页（写信/草稿/规则/标签管理）：继承原 header+main 结构 ===== */
.main { flex: 1; min-width: 0; overflow-y: auto; }
header { background: #fff; padding: 18px 26px; border-bottom: 1px solid var(--border); }
header h1 { font-size: 20px; margin-bottom: 6px; }
.meta { display: flex; gap: 24px; font-size: 13px; color: #6b7280; align-items: center; flex-wrap: wrap; }
main { padding: 22px 26px; max-width: 1100px; }
.compose-card { background: #fff; border-radius: 8px; padding: 20px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.compose-card select, .compose-card input, .compose-card textarea { padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; }
.compose-card textarea { resize: vertical; line-height: 1.6; }
.compose-original { font-size: 13px; padding: 10px 12px; background: var(--bg); border-radius: 6px; border-left: 3px solid var(--indigo); }
.compose-actions { display: flex; align-items: center; gap: 8px; }
.login-error { color: var(--red); font-size: 12px; }
.rule-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f3f4f6; font-size: 13px; background: #fff; padding: 8px 12px; border-radius: 6px; margin-bottom: 3px; }
.rule-item .btn { font-size: 11px; padding: 3px 8px; background: #fff; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; margin-left: auto; }

/* ===== 登录 ===== */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--bg); }
.login-card { width: 320px; padding: 32px; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 18px; text-align: center; }
.login-card input { padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }

/* ===== embedded（右栏展开模式）：无侧栏，内容全宽 ===== */
body.embedded .main { flex: 1; width: 100%; overflow-y: auto; }
body.embedded .sidebar { display: none; }

/* ===== 手机（P4 降级：隐藏左栏，列表全宽，详情抽屉） ===== */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .workspace.has-detail .list-pane { flex: 0 0 100%; }
  .workspace.has-detail .detail-pane { position: fixed; inset: 0; z-index: 20; border-left: none; }
}
