
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f3f5f9;
  --panel: #ffffff;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-sub: #64748b;
  --danger: #dc2626;
  --star: #f59e0b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
button { font-family: inherit; }
input, textarea { font-family: inherit; font-size: 14px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 40px 36px; width: 400px;
  max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 42px; height: 42px; background: var(--primary); color: #fff; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; }
.brand h1 { font-size: 22px; }
.login-sub { color: var(--text-sub); margin: 8px 0 24px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--text-sub); font-size: 13px; }
.form-row input, .modal-body input { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; outline: none; }
.form-row input:focus, .modal-body input:focus { border-color: var(--primary); }
.error-text { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.login-tips { margin-top: 16px; font-size: 12px; color: var(--text-sub); text-align: center; }

.btn { padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: background .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-sub); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-block { width: 100%; padding: 11px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-file { position: relative; overflow: hidden; display: inline-block; }
.btn-file input { position: absolute; left: 0; top: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; padding: 6px 10px;
  border-radius: 6px; color: var(--text-sub); }
.icon-btn:hover { background: #f1f5f9; }

.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 220px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { padding: 18px 16px; font-size: 17px; font-weight: 600; color: #fff; }
.btn-compose { margin: 4px 14px 14px; background: var(--primary); color: #fff; font-weight: 500; }
.folder-list { flex: 1; overflow-y: auto; }
.folder-item { padding: 9px 18px; cursor: pointer; display: flex; justify-content: space-between;
  align-items: center; border-left: 3px solid transparent; }
.folder-item:hover { background: rgba(255,255,255,.06); }
.folder-item.active { background: rgba(37,99,235,.25); border-left-color: var(--primary); color: #fff; }
.folder-item .badge { background: var(--primary); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 7px; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; }
.quota-bar { height: 5px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--primary); width: 0; }
.quota-text { margin: 6px 0 10px; color: #94a3b8; }
.user-box { display: flex; justify-content: space-between; align-items: center; }
.user-box a { color: #7dd3fc; text-decoration: none; }
.sidebar-mask { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 54px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 12px; }
.menu-btn { display: none; }
.search-box { flex: 1; max-width: 480px; }
.search-box input { width: 100%; padding: 8px 14px; border: 1px solid var(--border);
  border-radius: 20px; background: var(--bg); outline: none; }
.toolbar-spacer { flex: 1; }

.list-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.list-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border); font-size: 13px; }
.list-count { color: var(--text-sub); }
.message-list { flex: 1; overflow-y: auto; background: var(--panel); }
.msg-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer; }
.msg-item:hover { background: #f8fafc; }
.msg-item.unread { background: #eff6ff; }
.msg-item.unread .msg-subject { font-weight: 600; }
.msg-item .check { flex-shrink: 0; }
.msg-from { width: 180px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-weight: 500; }
.msg-main { flex: 1; min-width: 0; }
.msg-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { color: var(--text-sub); font-size: 12px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.msg-date { color: var(--text-sub); font-size: 12px; flex-shrink: 0; }
.msg-star { color: #cbd5e1; font-size: 16px; flex-shrink: 0; }
.msg-star.on { color: var(--star); }
.empty-tip { padding: 70px 20px; text-align: center; color: var(--text-sub); font-size: 13px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 10px; background: var(--panel); border-top: 1px solid var(--border); color: var(--text-sub); }

.read-pane { flex: 1; display: flex; flex-direction: column; background: var(--panel);
  overflow-y: auto; }
.read-toolbar { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--panel); z-index: 5; }
.read-content { padding: 24px 32px; flex: 1; }
.read-content h2 { font-size: 20px; margin-bottom: 12px; }
.read-meta { color: var(--text-sub); font-size: 13px; margin-bottom: 20px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border); line-height: 1.7; }
.read-body { line-height: 1.8; word-break: break-word; }
.read-body img { max-width: 100%; }
.attachments { padding: 0 32px 24px; display: flex; flex-wrap: wrap; gap: 10px; }
.attach-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; background: #f8fafc; }
.attach-chip a { color: var(--primary); text-decoration: none; }

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; width: 640px; max-width: 94vw;
  max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { padding: 16px 20px; font-size: 16px; font-weight: 600;
  border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.modal-close { cursor: pointer; color: var(--text-sub); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-body h3 { font-size: 14px; margin: 16px 0 8px; color: var(--text-sub); }
.modal-body input, .modal-body textarea { width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; outline: none; }
.compose-modal .modal-body input { margin-bottom: 8px; }
.compose-editor { width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; resize: vertical; outline: none; min-height: 180px; }
#compose-html-editor { background: #fff; }
.editor-tabs { display: flex; gap: 4px; margin: 8px 0; }
.tab { padding: 5px 14px; border: 1px solid var(--border); background: #f8fafc;
  border-radius: 6px; cursor: pointer; font-size: 13px; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.attach-row { display: flex; align-items: center; gap: 10px; margin-top: 10px;
  color: var(--text-sub); font-size: 13px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.switch { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }

.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 22px; border-radius: 8px;
  z-index: 200; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -220px; top: 0; bottom: 0; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .sidebar-mask.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .menu-btn { display: block; }
  .msg-from { width: 96px; }
  /* 列表里 .msg-preview 已显示时间，窄屏隐藏右侧重复的时间列 */
  .msg-date { display: none; }
  .msg-item { padding: 10px 12px; gap: 8px; }
  .list-toolbar { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .read-content { padding: 16px; }
  .attachments { padding: 0 16px 16px; }
}

/* 移动端悬浮写信按钮 */
.fab { display: none; }
@media (max-width: 860px) {
  .fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 16px; bottom: 72px; z-index: 30;
    width: 54px; height: 54px; border-radius: 50%; border: none;
    background: var(--primary, #2563eb); color: #fff; font-size: 22px;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .38); cursor: pointer;
  }
  .fab:active { transform: scale(.94); }
}
