/* ═══════════════ 邮箱 · 视觉系统 ═══════════════
   靛蓝为墨，朱砂为印 */

:root {
  --ink-900: #131f42;
  --ink-800: #1d2f5e;
  --ink-700: #27407c;
  --ink-600: #33549e;
  --vermilion: #d9482b;
  --vermilion-deep: #b93a20;
  --amber: #e8a33d;
  --teal: #1f8a70;
  --info: #2e6fd8;
  --magenta: #b84a8c;
  --danger: #c93030;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1e9d7;
  --surface-3: #e7dcc4;
  --overlay: #ffffff;
  --scrim: rgba(19, 31, 66, .45);
  --text: #2b2418;
  --text-2: #6d6350;
  --text-3: #9c9078;
  --line: #e3d8c0;
  --line-strong: #cfc2a4;
  --hover: rgba(217, 72, 43, .06);
  --active-row: #fbeee4;
  --mark: #f7d9a8;
  --shadow-1: 0 1px 3px rgba(43, 36, 24, .08), 0 4px 14px rgba(43, 36, 24, .06);
  --shadow-2: 0 6px 24px rgba(19, 31, 66, .16), 0 2px 8px rgba(19, 31, 66, .10);
  --shadow-3: 0 18px 60px rgba(19, 31, 66, .28);
  --radius: 12px;
  --sidebar-w: 248px;
  --topbar-h: 62px;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0e1424;
  --surface: #171f36;
  --surface-2: #1f2947;
  --surface-3: #2a3558;
  --overlay: #1a2340;
  --scrim: rgba(4, 8, 18, .62);
  --text: #ece5d3;
  --text-2: #a8a896;
  --text-3: #767b8f;
  --line: #2b3557;
  --line-strong: #3b4770;
  --hover: rgba(232, 163, 61, .07);
  --active-row: #26304f;
  --mark: #7a5a1e;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-2: 0 6px 24px rgba(0, 0, 0, .45);
  --shadow-3: 0 18px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 纸纹颗粒 */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .04 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--vermilion); color: #fff; }

/* ── 滚动条：走自己的视觉语言 ── */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--vermilion); background-clip: content-box; border: 2px solid transparent; }
.sidebar ::-webkit-scrollbar-thumb { background: var(--ink-600); background-clip: content-box; border: 2px solid transparent; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
kbd {
  font-family: var(--mono); font-size: 10px;
  border: 1px solid currentColor; border-radius: 4px;
  padding: 0 4px; opacity: .55; line-height: 1.5;
}

/* ═══════════ 布局骨架 ═══════════ */
.app { display: flex; height: 100vh; height: 100dvh; position: relative; z-index: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; min-height: 0; display: flex; gap: 0; }

/* ═══════════ 侧栏 ═══════════ */
.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: linear-gradient(178deg, var(--ink-800) 0%, var(--ink-900) 78%);
  color: #e9e2d0;
  position: relative;
  overflow-y: auto; overflow-x: hidden;
  z-index: 40;
}
.sidebar::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(420px 260px at -10% -6%, rgba(217, 72, 43, .22), transparent 65%),
    radial-gradient(360px 300px at 115% 108%, rgba(46, 111, 216, .25), transparent 65%);
}
.sidebar > * { position: relative; z-index: 1; }

.brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 14px; }
.brand-seal {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 24px; font-weight: 700; color: #fff8ee;
  background: linear-gradient(140deg, var(--vermilion) 10%, var(--vermilion-deep) 60%, #8f2b14);
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(217, 72, 43, .45), inset 0 0 0 1.5px rgba(255, 240, 220, .35);
  transform: rotate(-4deg);
}
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: 2px; }
.brand-sub { font-size: 10.5px; opacity: .55; letter-spacing: 1.5px; font-family: var(--serif); }
.sidebar-close { display: none; margin-left: auto; color: #e9e2d0; }

.compose-btn {
  margin: 8px 16px 16px;
  display: flex; align-items: center; gap: 9px;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--vermilion) 0%, #e06a2e 55%, var(--amber) 130%);
  color: #fff8ee; font-size: 15px; font-weight: 600; letter-spacing: 1px;
  box-shadow: 0 4px 16px rgba(217, 72, 43, .4);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s;
}
.compose-btn:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 7px 22px rgba(217, 72, 43, .5); }
.compose-btn:active { transform: translateY(0) scale(.98); }
.compose-btn kbd { margin-left: auto; }

.folder-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.folder-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: #cfc8b4; font-size: 13.5px;
  transition: background .13s, color .13s;
  position: relative; text-align: left; width: 100%;
}
.folder-item:hover { background: rgba(255, 248, 235, .08); color: #fff6e6; }
.folder-item.active {
  background: linear-gradient(90deg, rgba(217, 72, 43, .3), rgba(217, 72, 43, .12));
  color: #fff6e6; font-weight: 600;
}
.folder-item.active::before {
  content: ""; position: absolute; left: -10px; top: 20%; bottom: 20%;
  width: 3.5px; border-radius: 4px; background: var(--vermilion);
  box-shadow: 0 0 8px rgba(217, 72, 43, .8);
}
.folder-item svg { width: 17px; height: 17px; opacity: .85; }
.folder-badge {
  margin-left: auto; min-width: 21px; text-align: center;
  font-size: 11px; font-weight: 700; line-height: 19px; padding: 0 6px;
  border-radius: 10px; background: var(--vermilion); color: #fff8ee;
}
.folder-badge.dim { background: rgba(255, 248, 235, .14); color: #cfc8b4; font-weight: 500; }

.side-section { padding: 16px 10px 0; }
.side-title {
  font-size: 10.5px; letter-spacing: 2.5px; opacity: .45;
  padding: 0 12px 7px; font-weight: 600;
}
.label-nav, .saved-nav { display: flex; flex-direction: column; gap: 1px; }
.label-item, .saved-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: 8px; width: 100%;
  color: #cfc8b4; font-size: 13px; text-align: left;
  transition: background .13s, color .13s;
}
.label-item:hover, .saved-item:hover { background: rgba(255, 248, 235, .08); color: #fff6e6; }
.label-item.active, .saved-item.active { background: rgba(255, 248, 235, .12); color: #fff6e6; font-weight: 600; }
.label-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; box-shadow: 0 0 6px currentColor; }
.label-count { margin-left: auto; font-size: 11px; opacity: .5; }
.saved-item svg { width: 14px; height: 14px; opacity: .7; }
.saved-del { margin-left: auto; opacity: 0; padding: 2px; border-radius: 5px; display: grid; place-items: center; }
.saved-item:hover .saved-del { opacity: .6; }
.saved-del:hover { opacity: 1 !important; background: rgba(217, 72, 43, .35); }
.saved-del svg { width: 12px; height: 12px; }

.side-foot { margin-top: auto; padding: 18px 18px 16px; }
.storage { margin-bottom: 12px; }
.storage-row { display: flex; justify-content: space-between; font-size: 11px; opacity: .6; margin-bottom: 5px; }
.storage-bar { height: 5px; border-radius: 4px; background: rgba(255, 248, 235, .12); overflow: hidden; }
.storage-bar i {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--info), var(--teal), var(--amber));
  transition: width .5s ease;
}
.side-link {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #cfc8b4; opacity: .75; padding: 4px 0;
}
.side-link:hover { opacity: 1; color: #fff6e6; }
.side-link svg { width: 15px; height: 15px; }
.side-domain { font-size: 10.5px; opacity: .38; margin-top: 8px; font-family: var(--mono); letter-spacing: .5px; }

.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: var(--scrim); backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}

/* ═══════════ 顶栏 ═══════════ */
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
}
html[data-theme="dark"] .topbar { box-shadow: none; }
.menu-btn { display: none; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
  color: var(--text-2);
  transition: background .13s, color .13s, transform .1s;
}
.icon-btn:hover { background: var(--hover); color: var(--vermilion); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.danger:hover { background: rgba(201, 48, 48, .1); color: var(--danger); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.searchbox {
  flex: 1; max-width: 560px;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: 11px; padding: 0 12px; height: 40px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.searchbox:focus-within {
  border-color: var(--vermilion);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(217, 72, 43, .12);
}
.searchbox svg { color: var(--text-3); width: 16px; height: 16px; }
.searchbox input { flex: 1; min-width: 0; border: none; outline: none; background: none; height: 100%; }
.searchbox input::placeholder { color: var(--text-3); }
.searchbox input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 26px; height: 26px; }
.search-clear svg { width: 13px; height: 13px; }

.account-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; margin-left: 4px;
  border-radius: 22px; background: var(--surface-2);
  border: 1px solid var(--line);
}
.account-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  font-family: var(--serif); font-weight: 700; font-size: 14px; color: #fff8ee;
  background: linear-gradient(140deg, var(--ink-600), var(--ink-800));
}
.account-avatar.big { width: 42px; height: 42px; font-size: 20px; }
.account-mail { font-size: 12px; color: var(--text-2); font-family: var(--mono); }

/* ═══════════ 列表面板 ═══════════ */
.list-pane {
  flex: 1.05; min-width: 340px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  min-height: 0;
}
.read-pane-open .list-pane { flex: .9; }

.list-toolbar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.folder-title { font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.list-count { font-size: 12px; color: var(--text-3); }
.toolbar-spacer { flex: 1; }

.cbx { display: inline-flex; cursor: pointer; position: relative; }
.cbx input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.cbx i {
  width: 17px; height: 17px; border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  display: grid; place-items: center;
  transition: all .13s;
}
.cbx i::after {
  content: ""; width: 9px; height: 5px;
  border-left: 2px solid #fff8ee; border-bottom: 2px solid #fff8ee;
  transform: rotate(-45deg) scale(0); margin-top: -2px;
  transition: transform .13s;
}
.cbx input:checked + i, .cbx input:indeterminate + i { background: var(--vermilion); border-color: var(--vermilion); }
.cbx input:checked + i::after { transform: rotate(-45deg) scale(1); }
.cbx input:indeterminate + i::after { transform: scale(1); width: 9px; height: 0; border-left: none; border-bottom: 2.5px solid #fff8ee; margin-top: 0; }
.cbx:hover i { border-color: var(--vermilion); }

.filter-chips { display: flex; gap: 4px; }
.chip {
  padding: 4px 11px; border-radius: 16px; font-size: 12px;
  color: var(--text-2); border: 1px solid transparent;
  transition: all .13s;
}
.chip:hover { background: var(--hover); color: var(--vermilion); }
.chip.active {
  background: var(--ink-800); color: #f2ead6; font-weight: 600;
  box-shadow: 0 2px 6px rgba(19, 31, 66, .25);
}
html[data-theme="dark"] .chip.active { background: var(--vermilion); color: #fff8ee; }

.sort-select {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); padding: 4px 8px; font-size: 12px;
  color: var(--text-2); outline: none; cursor: pointer;
}
.sort-select:focus { border-color: var(--vermilion); }

.text-btn {
  font-size: 12.5px; color: var(--text-2); padding: 5px 9px; border-radius: 7px;
  transition: all .13s;
}
.text-btn:hover { background: var(--hover); color: var(--vermilion); }
.text-btn.danger:hover { background: rgba(201, 48, 48, .1); color: var(--danger); }
.text-btn.mini { font-size: 11.5px; padding: 3px 7px; white-space: nowrap; }

.bulk-bar {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: 8px 16px;
  background: linear-gradient(90deg, rgba(46, 111, 216, .1), rgba(31, 138, 112, .08));
  border-bottom: 1px solid var(--line);
  animation: slideDown .18s ease;
}
.bulk-bar > span { font-size: 12.5px; font-weight: 600; color: var(--info); margin-right: 6px; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } }

.mail-list { flex: 1; overflow-y: auto; min-height: 0; padding: 6px 8px 90px; }

/* ── 邮件行 ── */
.mail-row {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  align-items: center; gap: 10px;
  padding: 11px 10px;
  border-radius: 11px;
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, box-shadow .12s;
  animation: rowIn .25s ease backwards;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(5px); } }
.mail-row:hover { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1); }
.mail-row.selected { background: var(--active-row); border-color: rgba(217, 72, 43, .35); }
.mail-row.checked { background: rgba(46, 111, 216, .07); border-color: rgba(46, 111, 216, .3); }
.mail-row .cbx { opacity: 0; transition: opacity .12s; }
.mail-row:hover .cbx, .mail-row.checked .cbx, .mail-list.selecting .cbx { opacity: 1; }

.mail-avatar {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff8ee;
  font-family: var(--serif);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}
.mail-mid { min-width: 0; }
.mail-line1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mail-sender {
  font-size: 13.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 45%;
}
.mail-subject {
  font-size: 13.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.mail-row.unread .mail-sender, .mail-row.unread .mail-subject { color: var(--text); font-weight: 700; }
.mail-row.unread::before {
  content: ""; position: absolute; left: -1px; top: 30%; bottom: 30%;
  width: 3px; border-radius: 3px; background: var(--vermilion);
}
.mail-preview {
  font-size: 12px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 1px;
}
.mail-preview.lines-2 {
  white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.mail-tags { display: flex; gap: 5px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.tag-pill {
  font-size: 10.5px; padding: 1px 8px; border-radius: 9px;
  font-weight: 600; letter-spacing: .5px;
  border: 1px solid; line-height: 1.7;
}
.attach-flag { display: inline-flex; align-items: center; color: var(--text-3); }
.attach-flag svg { width: 13px; height: 13px; }

.mail-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.mail-time { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-family: var(--mono); }
.mail-row.unread .mail-time { color: var(--vermilion); font-weight: 700; }
.star-btn { padding: 2px; border-radius: 6px; color: var(--text-3); transition: transform .15s, color .15s; display: grid; place-items: center; }
.star-btn svg { width: 16px; height: 16px; }
.star-btn:hover { transform: scale(1.25); color: var(--amber); }
.star-btn.on { color: var(--amber); }
.star-btn.on svg { fill: var(--amber); }

.row-actions {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: none; gap: 2px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 2px; box-shadow: var(--shadow-1);
}
.mail-row:hover .row-actions { display: flex; }
.mail-row:hover .mail-meta { visibility: hidden; }
.row-actions .icon-btn { width: 30px; height: 30px; }
.row-actions svg { width: 15px; height: 15px; }

mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

/* 密度 */
.density-compact .mail-row { padding: 6px 10px; }
.density-compact .mail-avatar { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
.density-compact .mail-preview, .density-compact .mail-tags { display: none; }

/* 空状态 */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 24px; text-align: center; color: var(--text-3);
  animation: fadeIn .3s ease;
}
.empty-state svg { width: 74px; height: 74px; stroke-width: 1.1; margin-bottom: 16px; opacity: .5; }
.empty-title { font-family: var(--serif); font-size: 17px; color: var(--text-2); margin-bottom: 5px; letter-spacing: 1px; }
.empty-sub { font-size: 12.5px; }

/* 骨架屏 */
.skeleton-row { display: flex; gap: 12px; padding: 13px 10px; align-items: center; }
.skeleton-row .sk { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.1s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ═══════════ 阅读面板 ═══════════ */
.read-pane {
  flex: 1.25; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  animation: paneIn .22s ease;
}
@keyframes paneIn { from { opacity: 0; transform: translateX(10px); } }

.read-toolbar {
  flex: none; display: flex; align-items: center; gap: 3px;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
}
.read-back { display: none; }
.read-toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 5px; }

.read-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 22px 26px 60px; }
.read-subject { font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1.45; letter-spacing: .5px; margin-bottom: 6px; }
.read-tags { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.thread-count { font-size: 12px; color: var(--text-3); }

.msg-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--overlay); margin-bottom: 14px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.msg-head { display: flex; gap: 12px; padding: 15px 18px; align-items: flex-start; cursor: pointer; }
.msg-head-info { flex: 1; min-width: 0; }
.msg-from { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-from b { font-size: 14px; }
.msg-addr { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.msg-to { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.msg-to button { color: var(--info); font-size: 12px; padding: 0 3px; }
.msg-time { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-family: var(--mono); }
.msg-snippet { font-size: 12.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-body { padding: 4px 20px 18px; font-size: 14px; line-height: 1.85; border-top: 1px dashed var(--line); }
.msg-body p { margin: 10px 0; }
.msg-body blockquote {
  border-left: 3px solid var(--amber); padding: 4px 14px; margin: 10px 0;
  color: var(--text-2); background: var(--hover); border-radius: 0 8px 8px 0;
}
.msg-body a { color: var(--info); }
.msg-body ul, .msg-body ol { padding-left: 22px; margin: 8px 0; }
.msg-card.collapsed .msg-body, .msg-card.collapsed .msg-attachments, .msg-card.collapsed .msg-reply-row { display: none; }
.msg-card.collapsed .msg-head { padding: 11px 18px; }

.msg-attachments { padding: 0 20px 14px; display: flex; gap: 9px; flex-wrap: wrap; }
.attach-card {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 13px; background: var(--surface-2);
  transition: all .13s; cursor: pointer; text-align: left;
}
.attach-card:hover { border-color: var(--info); box-shadow: 0 3px 10px rgba(46, 111, 216, .18); transform: translateY(-1px); }
.attach-icon {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  color: #fff8ee; font-size: 9.5px; font-weight: 800; font-family: var(--mono);
  letter-spacing: .3px;
}
.attach-name { font-size: 12.5px; font-weight: 600; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { font-size: 11px; color: var(--text-3); }

.msg-reply-row { display: flex; gap: 8px; padding: 0 20px 18px; }
.reply-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--line-strong); border-radius: 20px;
  padding: 7px 18px; font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: all .14s;
}
.reply-btn:hover { border-color: var(--vermilion); color: var(--vermilion); background: var(--hover); transform: translateY(-1px); }
.reply-btn svg { width: 15px; height: 15px; }

.read-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-3); gap: 4px; padding: 30px; text-align: center; }
.read-empty .envelope-art { width: 150px; height: 150px; margin-bottom: 14px; }
.read-empty .empty-title { font-size: 18px; }
.shortcut-hints { display: flex; gap: 14px; margin-top: 16px; font-size: 12px; flex-wrap: wrap; justify-content: center; }
.shortcut-hints span { display: inline-flex; gap: 5px; align-items: center; }

/* ═══════════ 写信 ═══════════ */
.composer {
  position: fixed; right: 22px; bottom: 0; z-index: 60;
  width: 580px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  background: var(--overlay);
  border: 1px solid var(--line-strong);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-3);
  animation: composerIn .24s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes composerIn { from { opacity: 0; transform: translateY(40px); } }
.composer.fullscreen {
  inset: 4vh 6vw 0; width: auto; height: auto; max-height: none; max-width: none;
  border-radius: 16px 16px 0 0;
}
.composer-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  background: linear-gradient(120deg, var(--ink-800), var(--ink-900));
  color: #f2ead6; border-radius: 13px 13px 0 0;
  font-family: var(--serif); font-weight: 700; letter-spacing: 1.5px; font-size: 14.5px;
}
.composer.fullscreen .composer-head { border-radius: 15px 15px 0 0; }
.composer-head-actions { display: flex; gap: 2px; }
.composer-head .icon-btn { color: #cfc8b4; width: 30px; height: 30px; }
.composer-head .icon-btn:hover { background: rgba(255, 248, 235, .12); color: #fff6e6; }
.composer-head svg { width: 15px; height: 15px; }

.composer-fields { flex: none; padding: 4px 16px 0; }
.field-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.field-row label { font-size: 12.5px; color: var(--text-3); width: 46px; flex: none; }
.field-row input { flex: 1; min-width: 0; border: none; outline: none; background: none; padding: 9px 0; font-size: 13.5px; }
.field-row input::placeholder { color: var(--text-3); opacity: .7; }
.cmp-error {
  font-size: 12px; color: var(--danger); padding: 6px 2px;
  animation: shake .3s ease;
}
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.composer-tools {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: 6px 12px; border-bottom: 1px solid var(--line);
}
.tool-btn {
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
  color: var(--text-2); font-size: 13.5px; transition: all .12s;
}
.tool-btn:hover { background: var(--hover); color: var(--vermilion); }
.tool-btn svg { width: 15px; height: 15px; }
.tool-sep { width: 1px; height: 17px; background: var(--line); margin: 0 5px; }

.cmp-attachments { flex: none; display: flex; flex-wrap: wrap; gap: 7px; padding: 9px 16px 0; max-height: 96px; overflow-y: auto; }
.cmp-attach-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 6px 4px 10px; font-size: 12px;
}
.cmp-attach-chip .attach-size { font-size: 10.5px; }
.cmp-attach-chip button { display: grid; place-items: center; padding: 3px; border-radius: 5px; color: var(--text-3); }
.cmp-attach-chip button:hover { color: var(--danger); background: rgba(201, 48, 48, .1); }
.cmp-attach-chip svg { width: 12px; height: 12px; }

.cmp-body {
  flex: 1; min-height: 120px; overflow-y: auto;
  padding: 14px 18px; outline: none; font-size: 14px; line-height: 1.8;
}
.cmp-body:empty::before { content: attr(data-placeholder); color: var(--text-3); opacity: .6; pointer-events: none; }
.cmp-body blockquote { border-left: 3px solid var(--amber); padding: 4px 12px; margin: 8px 0; color: var(--text-2); background: var(--hover); }
.cmp-body .signature { color: var(--text-3); font-size: 13px; margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 10px; white-space: pre-wrap; }

.composer-foot {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-top: 1px solid var(--line);
}
.send-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(120deg, var(--vermilion), #e06a2e);
  color: #fff8ee; font-weight: 700; font-size: 14px; letter-spacing: 2px;
  padding: 9px 26px; border-radius: 10px;
  box-shadow: 0 3px 12px rgba(217, 72, 43, .35);
  transition: all .15s;
}
.send-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(217, 72, 43, .45); }
.send-btn:active { transform: scale(.97); }
.send-btn svg { width: 15px; height: 15px; }
.draft-hint { font-size: 11.5px; color: var(--text-3); }

/* ═══════════ 设置抽屉 ═══════════ */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: 360px; max-width: 92vw;
  background: var(--overlay);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  animation: drawerIn .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes drawerIn { from { transform: translateX(60px); opacity: 0; } }
.drawer-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { font-family: var(--serif); font-size: 17px; letter-spacing: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
.set-group { margin-bottom: 24px; }
.set-label { font-size: 12px; font-weight: 700; color: var(--text-2); letter-spacing: 1px; margin-bottom: 9px; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 13px; color: var(--text-2);
  transition: all .14s;
}
.seg button:hover { color: var(--vermilion); }
.seg button.active { background: var(--surface); color: var(--vermilion); font-weight: 700; box-shadow: var(--shadow-1); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.switch { position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; }
.switch i {
  display: block; width: 42px; height: 24px; border-radius: 14px;
  background: var(--surface-3); transition: background .18s; position: relative;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.3);
}
.switch input:checked + i { background: var(--teal); }
.switch input:checked + i::after { transform: translateX(18px); }

#signatureInput {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 10px 12px; font-size: 13px;
  outline: none; resize: vertical; line-height: 1.7;
}
#signatureInput:focus { border-color: var(--vermilion); }

.account-card { display: flex; gap: 12px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.account-name { font-weight: 700; font-size: 14px; }
.account-addr { font-size: 12px; color: var(--text-3); font-family: var(--mono); }

/* ═══════════ 弹窗 ═══════════ */
.modal-wrap {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: var(--scrim); backdrop-filter: blur(3px);
  animation: fadeIn .18s ease;
  padding: 20px;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 440px; max-width: 100%; max-height: 84dvh; overflow-y: auto;
  background: var(--overlay); border-radius: 16px;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-3);
  animation: modalIn .22s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.modal-head h3 { font-family: var(--serif); font-size: 16.5px; letter-spacing: 1.5px; }
.modal-body { padding: 14px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 0 20px 18px; }
.modal-input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 9px 12px; outline: none; font-size: 13.5px;
}
.modal-input:focus { border-color: var(--vermilion); }
.btn-primary {
  background: linear-gradient(120deg, var(--vermilion), #e06a2e); color: #fff8ee;
  font-weight: 700; padding: 8px 22px; border-radius: 9px; font-size: 13.5px;
  transition: all .14s; box-shadow: 0 2px 10px rgba(217, 72, 43, .3);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border: 1.5px solid var(--line-strong); color: var(--text-2); padding: 8px 18px; border-radius: 9px; font-size: 13.5px; }
.btn-ghost:hover { border-color: var(--text-3); }
.btn-danger { background: var(--danger); color: #fff; font-weight: 700; padding: 8px 22px; border-radius: 9px; font-size: 13.5px; }
.btn-danger:hover { filter: brightness(1.1); }

.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 22px; }
.shortcut-grid div { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-2); padding: 3px 0; }
.shortcut-grid kbd { font-size: 11px; opacity: .8; }

.label-menu { display: flex; flex-direction: column; gap: 2px; }
.label-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; font-size: 13.5px; transition: background .12s; text-align: left;
}
.label-menu-item:hover { background: var(--hover); }
.label-menu-item .cbx { pointer-events: none; }

/* ═══════════ Toast ═══════════ */
.toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink-900); color: #f2ead6;
  border: 1px solid rgba(255, 248, 235, .15);
  padding: 10px 16px; border-radius: 12px;
  box-shadow: var(--shadow-3); font-size: 13.5px;
  animation: toastIn .25s cubic-bezier(.2, .9, .3, 1.2);
  max-width: 92vw;
}
.toast.leaving { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.95); } }
.toast svg { width: 16px; height: 16px; }
.toast .t-ok { color: #6fd3b4; }
.toast .t-warn { color: var(--amber); }
.toast .t-info { color: #7fa9ee; }
.toast-action {
  color: var(--amber); font-weight: 700; padding: 3px 9px; border-radius: 7px;
  border: 1px solid rgba(232, 163, 61, .4); white-space: nowrap;
}
.toast-action:hover { background: rgba(232, 163, 61, .15); }

/* 新邮件横幅 */
.new-mail-banner {
  position: sticky; top: 4px; z-index: 5;
  margin: 0 auto 8px; width: max-content; max-width: 95%;
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(120deg, var(--info), var(--teal));
  color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 7px 16px; border-radius: 18px;
  box-shadow: 0 4px 16px rgba(46, 111, 216, .4);
  cursor: pointer; animation: toastIn .3s ease;
}
.new-mail-banner svg { width: 14px; height: 14px; }

/* ═══════════ 底部导航 ═══════════ */
.bottom-nav {
  flex: none;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 30;
}
.nav-item {
  flex: 1; max-width: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 0 7px; position: relative;
  color: var(--text-3); font-size: 11px; letter-spacing: 1px;
  transition: color .15s;
}
.nav-item:hover { color: var(--vermilion); }
.nav-item.active { color: var(--vermilion); font-weight: 700; }
.nav-item.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 30px; height: 3px; border-radius: 0 0 4px 4px; background: var(--vermilion);
}
.nav-icon { position: relative; display: grid; place-items: center; }
.nav-icon svg { width: 22px; height: 22px; stroke-width: 1.7; }
.nav-item.active .nav-icon svg { stroke-width: 2.1; }
.nav-badge {
  position: absolute; top: -5px; left: calc(50% + 5px);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 9px; background: var(--vermilion); color: #fff8ee;
  font-size: 9.5px; font-weight: 700; font-style: normal;
  display: grid; place-items: center; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}

/* ═══════════ 我的 ═══════════ */
.profile-page {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--surface);
  padding: 26px 18px calc(30px + env(safe-area-inset-bottom, 0));
}
.profile-inner { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.profile-head {
  display: flex; align-items: center; gap: 16px;
  padding: 22px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow-1);
}
.profile-avatar {
  width: 64px; height: 64px; flex: none; border-radius: 20px;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 30px; font-weight: 700; color: #fff8ee;
  background: linear-gradient(140deg, var(--vermilion) 10%, var(--vermilion-deep) 70%);
  box-shadow: 0 4px 14px rgba(217, 72, 43, .35);
}
.profile-name { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.profile-addr { font-size: 12.5px; color: var(--text-3); font-family: var(--mono); margin-top: 2px; }
.profile-domain { margin-left: auto; font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); padding: 14px 8px; text-align: center;
}
.stat-num { font-family: var(--serif); font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--text-3); letter-spacing: 1px; margin-top: 2px; }
.profile-section {
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); padding: 18px;
}
.profile-section h3 { font-family: var(--serif); font-size: 15px; letter-spacing: 1.5px; margin-bottom: 13px; }
.profile-storage-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.profile-storage-bar { height: 7px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.profile-storage-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--info), var(--teal), var(--amber)); }
#profileSignature {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 10px 12px; font-size: 13px;
  outline: none; resize: vertical; line-height: 1.7;
}
#profileSignature:focus { border-color: var(--vermilion); }
.profile-hint { font-size: 11.5px; color: var(--text-3); margin-top: 7px; }
.profile-footer { text-align: center; font-size: 11px; color: var(--text-3); font-family: var(--mono); padding-top: 6px; }

/* ═══════════ 响应式 ═══════════ */
@media (max-width: 1180px) {
  .read-pane {
    position: fixed; inset: 0; z-index: 50;
    animation: paneIn .2s ease;
  }
  .read-back { display: grid; }
  .list-pane { min-width: 0; border-right: none; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.2, .9, .3, 1);
    box-shadow: var(--shadow-3);
    width: 270px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .menu-btn { display: grid; }
  .account-mail { display: none; }
  .account-chip { padding: 4px; border: none; background: none; }
  .topbar { padding: 0 10px; gap: 4px; }
  .filter-chips { order: 5; width: 100%; }
  .list-toolbar { gap: 7px; padding: 9px 12px; }
  .mail-list { padding: 4px 6px 100px; }
  .mail-row { grid-template-columns: auto auto 1fr auto; gap: 8px; }
  .mail-row .cbx { display: none; }
  .mail-list.selecting .mail-row .cbx { display: inline-flex; }
  .mail-sender { max-width: 60%; }
  .row-actions { display: none !important; }
  .mail-row:hover .mail-meta { visibility: visible; }
  .composer { inset: 0; width: auto; height: 100dvh; max-height: none; max-width: none; border-radius: 0; border: none; }
  .composer-head { border-radius: 0; }
  .composer.fullscreen { inset: 0; border-radius: 0; }
  #composerExpand { display: none; }
  .read-scroll { padding: 16px 14px 60px; }
  .read-subject { font-size: 18px; }
  .toasts { bottom: 14px; }
  .shortcut-grid { grid-template-columns: 1fr; }
}