/* ============================================================
   芯邮 · 企业邮件系统
   设计令牌 / 布局 / 组件，按「桌面三栏 → 平板抽屉 → 手机单列」组织
   ============================================================ */

/* ── 令牌 ───────────────────────────────────────────────── */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #edf1f6;
  --border: #e4e9f0;
  --border-strong: #d3dae4;

  --text: #151d29;
  --text-2: #4b5768;
  --muted: #8592a3;

  --ink: #101a2b;
  --ink-2: #182642;
  --ink-line: rgba(255, 255, 255, .09);
  --ink-text: rgba(228, 236, 247, .74);
  --ink-text-strong: #f2f6fc;

  --brand: #2f6bff;
  --brand-dark: #1b4fd8;
  --brand-soft: #eaf1ff;

  --ok: #0f8a5f;
  --ok-soft: #e5f6ee;
  --warn: #a96f14;
  --warn-soft: #fdf3e2;
  --danger: #c4392f;
  --danger-soft: #fdecea;

  --radius: 12px;
  --radius-panel: 18px;

  --shadow-panel: 0 1px 2px rgba(16, 26, 43, .04), 0 12px 28px -18px rgba(16, 26, 43, .22);
  --shadow-pop: 0 32px 70px -24px rgba(16, 26, 43, .42);

  --rail-w: 254px;
  --list-w: 364px;
  --gap: 14px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, ul { margin: 0; }
button { font-family: inherit; }
a { color: var(--brand); }

.hidden { display: none !important; }
/* 属性选择器优先级低于类，必须单独兜底，否则 .icon-btn / .btn 会把 hidden 顶掉 */
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--muted); }

/* ── 通用控件 ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s, transform .1s;
}
.btn:hover { background: #e4e9f1; }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }

.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px -2px rgba(47, 107, 255, .55); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary:disabled { opacity: .6; cursor: default; transform: none; }

.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }

.btn.small { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn.small .ic { width: 14px; height: 14px; }
.btn.block { width: 100%; height: 46px; font-size: 14.5px; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.on-dark { color: var(--ink-text); }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 550;
  padding: 6px 4px;
  cursor: pointer;
  white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--danger-soft); color: var(--danger); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
}
.tag .ic { width: 12px; height: 12px; }

/* ── 品牌标识 ───────────────────────────────────────────── */
.logo-chip {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: 0 2px 10px rgba(4, 12, 28, .28);
}
.logo-chip img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-chip.small { width: 34px; height: 34px; border-radius: 10px; }

/* ════════════════════════════════════════════════════════
   登录页
   ════════════════════════════════════════════════════════ */
.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 560px at 12% -10%, #e2ecff 0%, rgba(226, 236, 255, 0) 60%),
    radial-gradient(900px 500px at 100% 110%, #e8eefb 0%, rgba(232, 238, 251, 0) 62%),
    var(--bg);
}

.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.06fr 1fr;
  background: var(--surface);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 40px 90px -50px rgba(16, 26, 43, .5), 0 2px 6px rgba(16, 26, 43, .06);
}

.login-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding: 40px 40px 36px;
  color: var(--ink-text-strong);
  background:
    radial-gradient(620px 320px at 110% 0%, rgba(47, 107, 255, .38) 0%, rgba(47, 107, 255, 0) 62%),
    linear-gradient(160deg, #16233c 0%, var(--ink) 58%, #0b1424 100%);
}
.login-aside-top { display: flex; align-items: center; gap: 13px; }
.login-brand-text { min-width: 0; }
.login-aside-name { font-size: 18px; font-weight: 680; letter-spacing: .2px; }
.login-aside-org { font-size: 12px; color: rgba(214, 226, 244, .6); margin-top: 2px; }

.login-aside-copy { margin-top: auto; }
.login-aside-title {
  font-size: 27px;
  line-height: 1.4;
  font-weight: 660;
  letter-spacing: -.4px;
  margin-bottom: 14px;
}
.login-aside-text { font-size: 13.5px; line-height: 1.85; color: var(--ink-text); }

.login-aside-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: auto;
}
.login-aside-list li { display: flex; align-items: flex-start; gap: 12px; }
.login-aside-list .li-ic {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .09);
  color: #8fb4ff;
  flex: 0 0 auto;
}
.login-aside-list .li-ic .ic { width: 16px; height: 16px; }
.login-aside-list strong { display: block; font-size: 13px; font-weight: 600; }
.login-aside-list small { display: block; font-size: 11.5px; color: rgba(200, 214, 235, .55); margin-top: 1px; }

.login-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 46px 34px;
}
.login-card { width: 100%; max-width: 340px; margin: 0 auto; }
.login-head { margin-bottom: 26px; }
.login-head h1 { font-size: 23px; font-weight: 660; letter-spacing: -.3px; }
.login-head p { font-size: 13px; color: var(--muted); margin-top: 6px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 7px; }
.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: #a6b1c0; }
.field input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(47, 107, 255, .14);
}
#login-form .btn.block { margin-top: 8px; }

.login-error {
  min-height: 18px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--danger);
}
.login-foot {
  margin-top: auto;
  padding-top: 34px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

/* ════════════════════════════════════════════════════════
   应用骨架
   ════════════════════════════════════════════════════════ */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  gap: var(--gap);
  padding: var(--gap);
  overflow: hidden;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(9, 16, 30, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

/* ── 左侧栏 ─────────────────────────────────────────────── */
.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  border-radius: var(--radius-panel);
  background: var(--ink);
  color: var(--ink-text);
  overflow: hidden;
}

.rail-brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 0 4px; }
.rail-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.rail-brand-text strong { font-size: 15.5px; font-weight: 680; color: var(--ink-text-strong); letter-spacing: .3px; }
.rail-brand-text small {
  font-size: 10.5px;
  color: rgba(200, 214, 235, .5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compose-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  margin: 20px 0 18px;
  border: 0;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: 0 8px 20px -10px rgba(47, 107, 255, .9);
  transition: background .14s, transform .1s;
}
.compose-btn:hover { background: var(--brand-dark); }
.compose-btn:active { transform: translateY(1px); }
.compose-btn .ic { width: 17px; height: 17px; stroke-width: 2; }

.folders { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.folder-item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 40px;
  padding: 0 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-text);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .13s, color .13s;
}
.folder-item .ic { width: 17px; height: 17px; color: rgba(160, 183, 214, .82); }
.folder-item .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item:hover { background: rgba(255, 255, 255, .07); color: var(--ink-text-strong); }
.folder-item.active { background: rgba(47, 107, 255, .2); color: #fff; font-weight: 600; }
.folder-item.active .ic { color: #9dbcff; }
.folder-item .badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.folder-item.active .badge { background: var(--brand); }

.rail-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }

.quota-box { padding: 0 6px; }
.quota-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  color: rgba(190, 206, 230, .5);
  margin-bottom: 6px;
  white-space: nowrap;
}
.quota-bar { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.quota-bar > div { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #4f83ff, #79a6ff); transition: width .4s; }

.rail-account {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
}
.rail-account .icon-btn { width: 26px; height: 26px; border-radius: 8px; }
.rail-account .icon-btn .ic { width: 15px; height: 15px; }
.rail-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #4f83ff, #2f5be0);
  color: #fff;
  font-size: 12.5px;
  font-weight: 650;
}
.rail-account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.rail-account-text strong {
  font-size: 11.5px;
  font-weight: 550;
  color: var(--ink-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-account-text small {
  font-size: 10.5px;
  color: rgba(190, 206, 230, .52);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 工作区 ─────────────────────────────────────────────── */
.workspace { flex: 1; display: flex; gap: var(--gap); min-width: 0; }

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.list-pane { flex: 0 0 var(--list-w); width: var(--list-w); }
.reader-pane { flex: 1; }

/* 列表头 */
.pane-head { flex: 0 0 auto; padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 12px; }
.pane-head-row { display: flex; align-items: center; gap: 8px; }
.pane-head-row h2 { flex: 1; min-width: 0; font-size: 17px; font-weight: 660; letter-spacing: -.2px; }
.pane-head-row .count { font-size: 12px; color: var(--muted); white-space: nowrap; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-ic { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.search-wrap input::placeholder { color: #a6b1c0; }
.search-wrap input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .13);
}

/* 邮件列表 */
.message-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--border); }

.msg-item {
  display: block;
  width: 100%;
  padding: 14px 18px 15px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  text-align: left;
  position: relative;
  cursor: pointer;
  transition: background .12s;
}
.msg-item:last-child { border-bottom: 0; }
.msg-item:hover { background: var(--surface-2); }
.msg-item.active { background: var(--brand-soft); }
.msg-item.active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 3px solid var(--brand);
  pointer-events: none;
}

.msg-row1 { display: flex; align-items: baseline; gap: 10px; }
.msg-from {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-date { flex: 0 0 auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg-subject {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-snippet {
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.62;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.msg-item.unread { background: #fbfcfe; }
.msg-item.unread::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
}
.msg-item.unread .msg-from { color: var(--text); font-weight: 650; }
.msg-item.unread .msg-subject { color: var(--text); font-weight: 600; }
.msg-item.unread .msg-snippet { color: var(--text-2); }

/* 空状态 */
.empty, .reader-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 24px;
  text-align: center;
}
.empty-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--surface-2);
  color: #b6c1d0;
  margin-bottom: 10px;
}
.empty-mark .ic { width: 24px; height: 24px; stroke-width: 1.5; }
.empty-mark.large { width: 64px; height: 64px; border-radius: 20px; }
.empty-mark.large .ic { width: 28px; height: 28px; }
.empty strong, .reader-empty strong { font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty p, .reader-empty p { font-size: 12.5px; color: var(--muted); }

/* ── 阅读区 ─────────────────────────────────────────────── */
.reader { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }

.reader-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
}

.reader-subject {
  font-size: 21px;
  line-height: 1.4;
  font-weight: 660;
  letter-spacing: -.3px;
  margin: 22px 28px 16px;
  word-break: break-word;
}

.reader-meta {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin: 0 28px 4px;
  padding: 15px 16px;
  border-radius: 14px;
  background: var(--surface-2);
}
.avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #6f9bff, #2f5be0);
  color: #fff;
  font-size: 16px;
  font-weight: 650;
}
.meta-main { flex: 1; min-width: 0; }
.meta-from { font-size: 13.5px; font-weight: 620; color: var(--text); word-break: break-word; }
.meta-from span { font-size: 12.5px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.meta-sub { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-word; line-height: 1.6; }
.meta-side {
  flex: 0 0 auto;
  text-align: right;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.8;
  font-variant-numeric: tabular-nums;
}
.meta-side .tag { margin-top: 4px; }
.dkim-badge { border-radius: 6px; }
.dkim-badge.pass { background: var(--ok-soft); color: var(--ok); }
.dkim-badge.warn { background: var(--warn-soft); color: var(--warn); }
.dkim-badge.fail { background: var(--danger-soft); color: var(--danger); }

/* 外部图片提示条 */
.remote-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 28px 0;
  padding: 11px 14px;
  border: 1px solid #e3dcc8;
  border-radius: 11px;
  background: #fdfaf1;
  font-size: 12.5px;
  color: #7a6a45;
}
.remote-bar .ic { width: 16px; height: 16px; color: #b09454; }
.remote-bar span { flex: 1; min-width: 0; }

.msg-body-frame { width: 100%; border: 0; display: block; background: #fff; }
.msg-body-text {
  padding: 20px 28px 32px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  word-break: break-word;
}

.section-title {
  margin: 24px 28px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .4px;
}
.attachment-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 28px 8px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: background .13s, border-color .13s;
}
.attachment-card:hover { background: var(--surface-2); border-color: var(--border-strong); }
.attachment-card .ic { color: var(--muted); }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }

/* ── 悬浮写信 ───────────────────────────────────────────── */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  z-index: 38;
  box-shadow: 0 14px 30px -10px rgba(47, 107, 255, .85);
  transition: transform .12s, box-shadow .12s;
}
.fab .ic { width: 23px; height: 23px; stroke-width: 2; }
.fab:active { transform: scale(.94); }
body.reading .fab { display: none; }

/* ════════════════════════════════════════════════════════
   弹窗（写信 / 后台）
   ════════════════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(9, 16, 30, .52);
  backdrop-filter: blur(3px);
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 90vh;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 17px; font-weight: 660; letter-spacing: -.2px; }
.modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.compose-card { max-width: 680px; }
.compose-body { flex: 1; overflow-y: auto; padding: 6px 22px 10px; }

.compose-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.compose-row label { flex: 0 0 52px; font-size: 12.5px; font-weight: 550; color: var(--muted); }
.compose-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 2px 0;
}
.compose-row input:focus { outline: none; }
.compose-row input::placeholder { color: #aab5c4; }

.compose-textarea {
  width: 100%;
  min-height: 240px;
  margin-top: 14px;
  padding: 0;
  border: 0;
  resize: vertical;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.85;
  font-family: inherit;
}
.compose-textarea:focus { outline: none; }
.compose-textarea::placeholder { color: #aab5c4; }

.attachment-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0 6px; }
.attachment-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 12px;
  color: var(--text-2);
  max-width: 260px;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 2px; border-radius: 50%; }
.chip button:hover { background: rgba(0, 0, 0, .07); color: var(--text); }

.compose-error { min-height: 18px; font-size: 12.5px; color: var(--danger); margin-top: 6px; }

.modal-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ── 管理后台 ───────────────────────────────────────────── */
.admin-card { max-width: 1000px; height: 88vh; }
.admin-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 13px 12px 12px;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: color .13s;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--brand); font-weight: 620; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}

.admin-body { flex: 1; overflow-y: auto; padding: 22px 24px 32px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { padding: 15px 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2); }
.stat .k { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.stat .v { font-size: 19px; font-weight: 660; letter-spacing: -.4px; word-break: break-all; line-height: 1.35; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
table.grid td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td, table.grid tr:hover td { background: var(--surface-2); }

.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.nowrap { white-space: nowrap; }

.hint-box {
  padding: 13px 15px;
  border: 1px solid #f0e2bf;
  border-radius: 12px;
  background: #fdf8ec;
  color: #7a6428;
  font-size: 12.5px;
  line-height: 1.75;
  margin-bottom: 20px;
}
.hint-box a { color: #9a6b00; font-weight: 550; }

.cert-panel {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  padding: 16px 18px;
}
.cert-head { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.cert-days { font-size: 12px; color: var(--muted); }
.cert-days.warn { color: var(--warn); font-weight: 550; }
.cert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 15px 24px; margin: 0; }
.cert-grid dt { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.cert-grid dd { margin: 0; font-size: 13px; color: var(--text); word-break: break-word; line-height: 1.6; }
.cert-grid .wide { grid-column: 1 / -1; }

.admin-body .section-title { margin: 24px 0 10px; }
.admin-body > .section-title:first-child { margin-top: 0; }
.admin-body > table.grid:last-child { margin-bottom: 0; }

.admin-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 6px 0 20px; }
.admin-form .f { display: flex; flex-direction: column; gap: 6px; min-width: 148px; }
.admin-form .f span { font-size: 11.5px; color: var(--muted); }
.admin-form .f input, .admin-form .f select {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
.admin-form .f input:focus, .admin-form .f select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .13);
}

.log-area {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}
.log-line {
  display: grid;
  grid-template-columns: 132px 66px 1fr;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  align-items: baseline;
}
.log-line:last-child { border-bottom: 0; }
.log-line .log-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.log-line .log-msg { color: var(--text-2); word-break: break-word; }
.log-line.error .log-msg { color: var(--danger); }
.log-line.warn .log-msg { color: var(--warn); }

.cert-card, .kv {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px 16px;
  background: var(--surface-2);
}

/* ── 提示条 ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  z-index: 90;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 18px;
  border-radius: 11px;
  background: #1b2436;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 16px 34px -14px rgba(9, 16, 30, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); }

/* ── 响应式开关 ─────────────────────────────────────────── */
.only-narrow { display: none; }
.only-mobile { display: none; }

/* ── 中等屏 ─────────────────────────────────────────────── */
@media (max-width: 1240px) {
  :root { --list-w: 330px; --rail-w: 234px; }
  .rail-account-text strong { font-size: 11px; }
  .rail-account-text small { font-size: 10px; }
}

@media (max-width: 1080px) {
  :root { --gap: 10px; --rail-w: 220px; --list-w: 310px; }
  .rail { padding: 16px 10px 12px; }
  .rail-brand-text small { display: none; }
  .reader-subject { font-size: 19px; margin: 18px 20px 14px; }
  .reader-meta { margin: 0 20px 4px; }
  .remote-bar { margin: 14px 20px 0; }
  .section-title { margin: 20px 20px 10px; }
  .attachment-card { margin: 0 20px 8px; }
  .msg-body-text { padding: 18px 20px 28px; }
  .reader-toolbar { padding: 10px 14px; }
  .reader-toolbar .btn.small { padding: 0 10px; font-size: 12px; }
}

/* 侧栏变抽屉 */
@media (max-width: 900px) {
  .only-narrow { display: inline-flex; }

  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    width: 280px;
    border-radius: 0 18px 18px 0;
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.32, .72, 0, 1);
    padding: 18px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }
  body.nav-open .rail { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }

  .list-pane { flex: 1 1 auto; width: auto; }
  .reader-pane { flex: 1 1 46%; }
}

/* ════════════════════════════════════════════════════════
   手机：列表单页 + 阅读整屏
   ════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  :root { --gap: 0; }

  .only-mobile { display: inline-flex; }

  .app { padding: 0; gap: 0; }

  .workspace { gap: 0; }
  .panel { border-radius: 0; box-shadow: none; }
  .list-pane { flex: 1 1 100%; width: 100%; }

  .pane-head {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 12px;
    gap: 12px;
    background: var(--surface);
  }
  .pane-head-row h2 { font-size: 19px; }
  .pane-head-row .icon-btn { width: 40px; height: 40px; }
  .search-wrap input { height: 42px; font-size: 14px; border-radius: 11px; }

  .msg-item { padding: 15px 18px 16px; }
  .msg-from { font-size: 14.5px; }
  .msg-date { font-size: 12px; }
  .msg-subject { font-size: 14.5px; margin-top: 5px; }
  .msg-snippet { font-size: 13px; -webkit-line-clamp: 2; margin-top: 4px; }

  /* 阅读层整屏覆盖，带滑入动画 */
  .reader-pane {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: none;
    border-radius: 0;
    background: var(--surface);
  }
  body.reading .reader-pane { display: flex; animation: slide-in .2s ease; }
  @keyframes slide-in { from { transform: translateX(14px); opacity: .6; } to { transform: none; opacity: 1; } }
  body.reading { overflow: hidden; }

  .reader { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .reader-toolbar {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .reader-toolbar::-webkit-scrollbar { display: none; }
  .reader-toolbar .btn { flex: 0 0 auto; height: 34px; }
  .reader-toolbar .btn.small { font-size: 12.5px; padding: 0 11px; }

  .reader-subject { font-size: 19px; line-height: 1.42; margin: 18px 18px 14px; }
  .reader-meta { margin: 0 18px 4px; padding: 13px; gap: 11px; }
  .avatar { width: 36px; height: 36px; border-radius: 11px; font-size: 15px; }
  .meta-side { font-size: 11px; }
  .meta-from span { display: block; margin-left: 0; }

  .remote-bar { margin: 14px 18px 0; flex-wrap: nowrap; align-items: flex-start; gap: 9px; }
  .remote-bar .ic { margin-top: 2px; }
  .remote-bar span { flex: 1 1 auto; min-width: 0; font-size: 12.5px; line-height: 1.55; }
  .remote-bar .btn { flex: 0 0 auto; align-self: center; }

  .msg-body-text { padding: 18px 18px 32px; font-size: 15px; line-height: 1.85; }
  .section-title { margin: 22px 18px 10px; }
  .attachment-card { margin: 0 18px 8px; padding: 12px 14px; }

  /* 弹窗变底部抽屉 */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-height: 93dvh; border-radius: 20px 20px 0 0; }
  .modal-head { padding: 16px 18px 14px; }
  .modal-head h3 { font-size: 16px; }
  .compose-body { padding: 4px 18px 8px; }
  .compose-row { padding: 14px 0; }
  .compose-row label { flex-basis: 46px; font-size: 13px; }
  .compose-row input { font-size: 15px; }
  .compose-textarea { min-height: 34dvh; font-size: 15px; resize: none; }
  .modal-foot {
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }
  .modal-foot .btn { flex: 1; height: 46px; font-size: 14.5px; }
  .modal-foot .muted { display: none; }

  .admin-card { height: 93dvh; max-width: none; }
  /* 8 个标签在手机上一行放不下，换行铺开，别让用户猜右边还有东西 */
  .admin-tabs { padding: 0 14px 6px; flex-wrap: wrap; overflow: visible; gap: 0 2px; }
  .tab { padding: 12px 10px 10px; font-size: 12.5px; }
  .tab.active::after { left: 6px; right: 6px; }
  .admin-body { padding: 16px 16px calc(28px + env(safe-area-inset-bottom, 0px)); }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 13px; }
  .stat .v { font-size: 15px; }
  table.grid { font-size: 12.5px; }
  table.grid th, table.grid td { padding: 10px 9px; }
  table.ports td:first-child { white-space: nowrap; }
  .log-line { grid-template-columns: 1fr; gap: 2px; padding: 10px 14px; }
  .log-line .log-time { order: -1; }

  .toast { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }

  /* 登录页：单列 */
  .login-view { padding: 0; display: block; }
  .login-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .login-aside {
    padding: calc(28px + env(safe-area-inset-top, 0px)) 24px 26px;
    border-radius: 0 0 26px 26px;
    gap: 0;
  }
  .login-aside-copy { margin-top: 22px; }
  .login-aside-title { font-size: 21px; margin-bottom: 10px; }
  .login-aside-text { font-size: 13px; }
  .login-aside-list { display: none; }
  .login-main { flex: 1; padding: 30px 24px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .login-card { max-width: 420px; }
  .login-head { margin-bottom: 22px; }
  .login-head h1 { font-size: 21px; }
  .field input { height: 50px; font-size: 15px; }
  #login-form .btn.block { height: 50px; }
  .login-foot { margin-top: 26px; padding-top: 0; }
}

/* 很矮的窗口（横屏手机） */
@media (max-height: 560px) {
  .modal { padding: 10px; align-items: center; }
  .modal-card { max-height: 96vh; }
  .admin-card { height: 96vh; }
  .compose-textarea { min-height: 120px; }
}

/* 尊重减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
