/* ==========================================================================
   Angus Mail · 样式
   图片位：assets/img/logo.svg（左上角标志）、assets/img/login-bg.jpg（登录页大图）
   直接替换同名文件即可生效，无需改代码。
   ========================================================================== */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --line: #e5e8ee;
  --line-2: #eef1f5;
  --ink: #171b22;
  --ink-2: #5a6472;
  --ink-3: #8d95a3;
  --brand: #3563e9;
  --brand-soft: #eaf0ff;
  --brand-ink: #ffffff;
  --danger: #d64545;
  --danger-soft: #fdeced;
  --ok: #2f9e6f;
  --shadow-1: 0 1px 2px rgba(19, 26, 38, .05), 0 4px 14px -6px rgba(19, 26, 38, .10);
  --shadow-2: 0 12px 40px -12px rgba(19, 26, 38, .28);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro SC", "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --panel: #151a21;
    --panel-2: #1a2028;
    --line: #262d38;
    --line-2: #1f252e;
    --ink: #e8ecf2;
    --ink-2: #a4adbb;
    --ink-3: #6f7887;
    --brand: #5b82f0;
    --brand-soft: #1c2740;
    --danger: #e26868;
    --danger-soft: #33201f;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 16px 48px -16px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
img { display: block; }
[hidden] { display: none !important; }

/* ------------------------------ 通用控件 ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--panel); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background .15s ease, border-color .15s ease, transform .08s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 18px -10px var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; height: 44px; }

.icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line-2); }
.icon.danger:hover { color: var(--danger); background: var(--danger-soft); }

.fld { display: block; margin: 0 0 14px; }
.fld > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; letter-spacing: .01em; }
.fld input {
  width: 100%; height: 44px; padding: 0 13px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--panel);
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.fld input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fld.row { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 10px; margin: 0; padding: 10px 18px; border-bottom: 1px solid var(--line-2); }
.fld.row > span { margin: 0; }
.fld.row input { border: none; height: 30px; padding: 0; background: transparent; border-radius: 0; }
.fld.row input:focus { box-shadow: none; }

/* ------------------------------ 登录页 ------------------------------ */
.is-login { background: var(--bg); }
.login {
  display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr);
  min-height: 100vh;
}

.login-art {
  position: relative; overflow: hidden;
  background-color: #101a33;
  background-image: radial-gradient(120% 90% at 18% 12%, #2f4b8f 0%, #16203a 46%, #0b1120 100%);
  color: #eef3ff;
  display: flex; align-items: center;
  padding: 64px clamp(32px, 6vw, 84px);
}
/* 背景大图：把 login-bg.jpg 放进 assets/img/ 即自动生效（没有图时用渐变） */
.login-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}
.login-art::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 13, 26, .18) 0%, rgba(8, 13, 26, .55) 100%);
}
.login-art-inner { position: relative; z-index: 1; max-width: 480px; }
.brand-mark { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: .01em; }
.brand-mark img { border-radius: 9px; }
.brand-mark span { font-size: 17px; }
.login-art h1 {
  margin: 30px 0 14px; font-size: clamp(28px, 3.2vw, 40px); line-height: 1.22;
  font-weight: 700; letter-spacing: -.015em;
}
.login-sub { margin: 0; color: rgba(232, 240, 255, .74); font-size: 15px; max-width: 420px; }
.login-points { list-style: none; margin: 34px 0 0; padding: 0; display: grid; gap: 13px; }
.login-points li { display: flex; align-items: center; gap: 11px; color: rgba(232, 240, 255, .86); font-size: 14px; }
.login-points i {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, .12); position: relative;
}
.login-points i::after {
  content: ""; position: absolute; left: 6px; top: 6px; width: 8px; height: 5px;
  border-left: 1.6px solid #9fc2ff; border-bottom: 1.6px solid #9fc2ff;
  transform: rotate(-45deg);
}

.login-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 56px clamp(24px, 5vw, 64px); background: var(--panel);
}
.login-card { width: 100%; max-width: 372px; }
.login-card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.015em; }
.login-tip { margin: 0 0 26px; color: var(--ink-3); font-size: 13.5px; }
.pwd { position: relative; }
.pwd input { padding-right: 44px; }
.pwd-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink-3);
  cursor: pointer; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.pwd-eye:hover { color: var(--ink-2); background: var(--panel-2); }
.login-msg {
  margin: 2px 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
}
.login-note { margin: 18px 0 0; font-size: 12.2px; color: var(--ink-3); line-height: 1.6; }
.login-card .btn.block { margin-top: 10px; }
.login-foot { margin: 28px 0 0; font-size: 12px; color: var(--ink-3); }

/* ------------------------------ 邮箱主界面 ------------------------------ */
.app {
  display: grid; grid-template-columns: 232px 372px minmax(0, 1fr);
  height: 100vh; height: 100dvh; overflow: hidden;
}

/* 侧栏 */
.side {
  display: flex; flex-direction: column; gap: 16px;
  padding: 18px 14px 14px; background: var(--panel-2);
  border-right: 1px solid var(--line); min-height: 0;
}
.side .brand-mark { padding: 2px 6px 4px; }
.side .brand-mark img { width: 30px; height: 30px; }
.side .brand-mark span { font-size: 15px; }
.compose { width: 100%; height: 42px; }

.folders { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; min-height: 0; }
.folder {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px; background: transparent;
  color: var(--ink-2); cursor: pointer; text-align: left; font-size: 13.6px;
}
.folder:hover { background: rgba(120, 135, 160, .10); color: var(--ink); }
.folder.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.folder .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .badge {
  min-width: 20px; height: 19px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.folder.on .badge { background: var(--brand); }
.folder svg { flex: none; opacity: .8; }

.side-foot {
  display: flex; align-items: center; gap: 8px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.me { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; font-size: 12.5px; color: var(--ink-3); }
.me .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.me-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 12.5px; padding: 4px 2px; }
.link:hover { color: var(--danger); }

/* 列表列 */
.listcol {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.listhead {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--line-2);
}
.listtitle { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; }
.listtitle h2 { margin: 0; font-size: 16.5px; letter-spacing: -.01em; }
.count { font-size: 12px; color: var(--ink-3); }
.back, .back2 { display: none; }

.search {
  display: flex; align-items: center; gap: 8px; margin: 10px 14px 8px;
  padding: 0 10px; height: 36px; border-radius: 10px;
  background: var(--bg); border: 1px solid transparent; color: var(--ink-3);
}
.search:focus-within { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none; height: 100%;
  font-size: 13.5px;
}
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 17px; line-height: 1; padding: 0 2px; }

.rows { flex: 1; overflow-y: auto; min-height: 0; padding: 2px 6px 8px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 11px 12px; border-radius: 11px; cursor: pointer;
  border: 1px solid transparent;
}
.row:hover { background: var(--panel-2); }
.row.on { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 18%, transparent); }
.row .r1 { display: flex; align-items: center; gap: 7px; min-width: 0; }
.row .from {
  font-size: 13.6px; font-weight: 500; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row.unread .from { color: var(--ink); font-weight: 700; }
.row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); flex: none; }
.row .when { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.row .subj {
  font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  grid-column: 1 / 2; display: flex; align-items: center; gap: 6px;
}
.row.unread .subj { color: var(--ink); font-weight: 600; }
.row .clip { color: var(--ink-3); flex: none; }
.row.skeleton { height: 60px; background: linear-gradient(90deg, var(--panel-2) 25%, var(--line-2) 37%, var(--panel-2) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 11px; margin: 4px 0; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.pager { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--ink-3); }
.pager button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; height: 28px; padding: 0 10px; cursor: pointer; color: var(--ink-2); }
.pager button:disabled { opacity: .4; cursor: default; }

/* 阅读列 */
.readcol { min-height: 0; overflow-y: auto; background: var(--panel); }
.empty-state {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--ink-3);
}
.empty-state img { opacity: .35; }
.empty-state p { margin: 0; font-size: 13.5px; }

.reader { padding: 22px clamp(20px, 4vw, 42px) 40px; max-width: 900px; }
.reader-head { border-bottom: 1px solid var(--line-2); padding-bottom: 16px; }
.reader-top { display: flex; align-items: flex-start; gap: 12px; }
.reader-top h1 {
  flex: 1; margin: 0; font-size: 20px; line-height: 1.38; letter-spacing: -.012em;
  font-weight: 650; word-break: break-word;
}
.reader-acts { display: flex; align-items: center; gap: 6px; flex: none; }

.reader-meta { display: flex; align-items: center; gap: 11px; margin-top: 16px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; text-transform: uppercase;
}
.who { flex: 1; min-width: 0; }
.who-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.who-line b { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-line span { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-line.sub { font-size: 12.3px; color: var(--ink-3); margin-top: 2px; }
#rdDate { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.att {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
  color: var(--ink-2); text-decoration: none; font-size: 12.8px; max-width: 100%;
}
.att:hover { border-color: var(--brand); color: var(--brand); }
.att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.att .sz { color: var(--ink-3); font-size: 11.5px; }

.reader-body { margin-top: 20px; }
.reader-body iframe {
  width: 100%; border: 0; display: block; background: #fff;
  border-radius: 10px; min-height: 120px;
}
.reader-body pre {
  white-space: pre-wrap; word-break: break-word; margin: 0;
  font-family: var(--sans); font-size: 14.2px; line-height: 1.72;
}

/* 写信抽屉 */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 22, .38); z-index: 60; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; z-index: 61; right: 24px; bottom: 0;
  width: min(620px, calc(100vw - 32px)); height: min(620px, 82vh);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; overflow: hidden;
  animation: up .2s cubic-bezier(.22, .9, .3, 1);
}
@keyframes up { from { transform: translateY(14px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--line-2); }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-head .icon { font-size: 22px; line-height: 1; }
.drawer-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.drawer-body textarea {
  flex: 1; min-height: 120px; resize: none; border: 0; outline: none;
  padding: 16px 18px; background: transparent; font-size: 14.2px; line-height: 1.72;
}
.drawer-msg { margin: 0 18px 8px; padding: 9px 11px; border-radius: 9px; font-size: 12.8px; background: var(--danger-soft); color: var(--danger); }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line-2); background: var(--panel-2); }
.drawer-foot .spacer { flex: 1; }
.drawer-foot .hint { font-size: 12px; color: var(--ink-3); }

/* 顶部轻提示 */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1b222d; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; z-index: 90; box-shadow: var(--shadow-2); animation: fade .16s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: #227a58; }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1080px) {
  .app { grid-template-columns: 200px 320px minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 34vh; padding: 34px 26px; align-items: flex-end; }
  .login-art h1 { font-size: 24px; margin: 18px 0 8px; }
  .login-points { display: none; }
  .login-sub { font-size: 13.5px; }
  .login-panel { padding: 30px 22px 40px; justify-content: flex-start; }

  .app { grid-template-columns: 1fr; }
  .side {
    flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px;
    border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto; overflow-y: hidden;
  }
  .side .brand-mark { padding: 0; flex: none; }
  .side .brand-mark span { display: none; }
  .compose { width: auto; height: 36px; padding: 0 13px; font-size: 13px; flex: none; }
  .folders { flex-direction: row; gap: 6px; flex: 1; overflow-x: auto; overflow-y: hidden; }
  .folder { flex: none; padding: 6px 11px; font-size: 13px; }
  .folder .badge { display: none; }
  .side-foot { border: 0; padding: 0; flex: none; }
  .me { display: none; }
  .link { font-size: 13px; }

  .listcol { border-right: 0; }
  .back { display: inline-flex; }
  .readcol { display: none; }
  body.reading .listcol { display: none; }
  body.reading .readcol { display: block; }
  body.reading .back { display: inline-flex; }
  .reader { padding: 16px 16px 40px; }
  .reader-top h1 { font-size: 17.5px; }
  .back2 { display: inline-flex; flex: none; }
  .drawer { right: 0; left: 0; width: 100%; height: 88vh; border-radius: 16px 16px 0 0; }
}

@media (max-width: 420px) {
  .reader-acts .btn { display: none; }
  .reader-acts #btnDelete { display: inline-flex; }
}
