/* ============================================================
   Paituo Mail — 界面样式（浅色）
   ============================================================ */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e8ee;
  --border-strong: #d6dae2;
  --text: #17191f;
  --text-2: #4b5563;
  --muted: #8b93a1;
  --accent: #2f6df6;
  --accent-hover: #2559d6;
  --accent-weak: #eaf0fe;
  --danger: #cf4436;
  --star: #e0a516;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .10), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .18);
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ------------------------------- 通用控件 ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #a9bdf2; cursor: not-allowed; transform: none; }
.btn-ghost { border-color: var(--border-strong); color: var(--text-2); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); border-color: #c3c8d2; }
.btn-block { width: 100%; height: 42px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: #eef0f4; color: var(--text); }
.icon-btn.active { color: var(--star); }

.only-mobile { display: none; }

/* ------------------------------- 登录 ------------------------------- */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 50% -12%, #e8eefc 0%, rgba(232, 238, 252, 0) 62%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 30px 26px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--accent-weak);
}

.login-title {
  margin: 0;
  text-align: center;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.login-sub {
  margin: 6px 0 26px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
.field input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder { color: #b3b9c4; }
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, .14);
}

.login-error {
  min-height: 18px;
  margin: 2px 0 12px;
  color: var(--danger);
  font-size: 12.5px;
}

.login-foot {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------- 顶栏 ------------------------------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-name { font-weight: 620; font-size: 15px; letter-spacing: -.01em; }

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 480px;
}
.search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #f1f3f7;
  outline: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, .13);
}

.user { display: flex; align-items: center; gap: 9px; margin-left: auto; flex: none; }
.avatar {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-addr { font-size: 12.5px; font-weight: 500; }
.user-plan { font-size: 11px; color: var(--muted); }

/* ------------------------------- 布局 ------------------------------- */

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 212px 372px minmax(0, 1fr);
}

/* ------------------------------- 侧栏 ------------------------------- */

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  overflow-y: auto;
}

.compose-btn { width: 100%; height: 40px; margin-bottom: 2px; }

.folders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.folder {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: background .13s ease, color .13s ease;
}
.folder:hover { background: #eef0f5; color: var(--text); }
.folder.active { background: var(--accent-weak); color: var(--accent); font-weight: 550; }
.folder-ico { font-size: 14px; width: 18px; text-align: center; flex: none; filter: saturate(.9); }
.folder-name { flex: 1; }

.badge {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 19px;
  text-align: center;
}
.badge:empty { display: none; }

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.quota-bar {
  height: 4px;
  border-radius: 2px;
  background: #e6e9ef;
  overflow: hidden;
}
.quota-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s ease; }
.quota-label { margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.side-link {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: none;
}
.side-link:hover { color: var(--accent); }

/* ------------------------------- 列表 ------------------------------- */

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 12px 0 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.list-head h2 { margin: 0; font-size: 14.5px; font-weight: 620; }

.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.item {
  display: block;
  width: 100%;
  padding: 12px 16px 12px 18px;
  border: 0;
  border-bottom: 1px solid #f0f2f6;
  background: transparent;
  text-align: left;
  transition: background .12s ease;
}
.item:hover { background: #f8f9fc; }
.item.active { background: var(--accent-weak); }
.item.unread { background: #fbfcff; }
.item.unread .item-subject { font-weight: 600; color: var(--text); }
.item.unread .item-from { font-weight: 600; }

.item-top { display: flex; align-items: baseline; gap: 8px; }
.item-from {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-time { flex: none; font-size: 11.5px; color: var(--muted); }
.item-subject {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-snippet {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-flags { display: inline-flex; gap: 5px; margin-left: 6px; vertical-align: middle; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }
.star-mark { color: var(--star); font-size: 12px; }

.list-empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.list-foot { flex: none; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.list-foot:empty { display: none; }
.list-foot button { border: 0; background: none; color: var(--accent); font-size: 12.5px; padding: 0 4px; }

/* ------------------------------- 阅读区 ------------------------------- */

.read-pane {
  min-width: 0;
  overflow-y: auto;
  background: var(--surface);
}

.empty-state {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.empty-state p { margin: 0; }

.read-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 24px 13px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--border);
}

.read-subject {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 620;
  line-height: 1.35;
  letter-spacing: -.01em;
  word-break: break-word;
}

.read-meta { display: flex; align-items: flex-start; gap: 11px; }
.read-avatar {
  width: 36px; height: 36px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #eef1f6;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.read-who { min-width: 0; flex: 1; }
.read-from { font-size: 13.5px; font-weight: 550; word-break: break-all; }
.read-to { font-size: 12px; color: var(--muted); margin-top: 1px; word-break: break-all; }

.read-actions { display: flex; gap: 2px; flex: none; }

.read-body { padding: 20px 24px 40px; }

.mail-frame {
  width: 100%;
  min-height: 320px;
  border: 0;
  display: block;
}

.mail-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 14px/1.7 inherit;
  color: var(--text);
}

.attachments { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.attachments h4 { margin: 0 0 9px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.att-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.att {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  text-decoration: none;
  transition: border-color .13s ease, background .13s ease;
}
.att:hover { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { color: var(--muted); font-size: 11.5px; flex: none; }

/* ------------------------------- 写信 ------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 20, 30, .38);
  backdrop-filter: blur(3px);
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 660px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .16s cubic-bezier(.2, .8, .3, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 14px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 620; }

.modal-body { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }

.row { display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid #f0f2f6; }
.row-label { flex: none; width: 56px; font-size: 12.5px; color: var(--muted); }
.row-input {
  flex: 1;
  height: 42px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  min-width: 0;
}
.row-input:focus { outline: none; }
select.row-input { cursor: pointer; }

.compose-body {
  margin: 14px 20px;
  padding: 12px;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: 9px;
  resize: vertical;
  outline: none;
  font: 13.5px/1.65 inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.compose-body:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 109, 246, .13); }

.attach-list { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 20px; }
.attach-list:empty { display: none; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 10px;
  border-radius: 7px;
  background: #f0f2f6;
  font-size: 12px;
  color: var(--text-2);
}
.attach-chip button { border: 0; background: none; color: var(--muted); padding: 0 2px; font-size: 14px; line-height: 1; }
.attach-chip button:hover { color: var(--danger); }

.compose-error { min-height: 16px; margin: 8px 20px 0; color: var(--danger); font-size: 12.5px; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex: none;
}
.spacer { flex: 1; }
.file-btn { position: relative; overflow: hidden; }

/* ------------------------------- Toast ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  transform: translate(-50%, 14px);
  padding: 10px 18px;
  border-radius: 10px;
  background: #1f2430;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: var(--shadow-md);
  max-width: min(86vw, 420px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b3392c; }

/* ------------------------------- 自适应 ------------------------------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 190px 330px minmax(0, 1fr); }
  .read-head, .read-body { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 880px) {
  .only-mobile { display: inline-flex; }
  .brand-name { display: none; }
  .layout { grid-template-columns: 1fr; }
  .side { display: none; }
  .list-pane { border-right: 0; }
  .read-pane { display: none; }
  .app.reading .list-pane { display: none; }
  .app.reading .read-pane { display: block; }
  .user-meta { display: none; }
  .read-subject { font-size: 16.5px; }
  .modal { padding: 0; place-items: end stretch; }
  .modal-card {
    max-width: none;
    max-height: 94dvh;
    border-radius: 16px 16px 0 0;
  }
  .compose-body { min-height: 150px; }
}

@media (max-width: 520px) {
  :root { --topbar-h: 54px; }
  .topbar { gap: 10px; padding: 0 10px; }
  .search input { height: 34px; font-size: 13px; }
  .item { padding: 11px 14px; }
  .login-card { padding: 28px 22px 22px; border-radius: 16px; }
}
