:root {
  --bg: #0d1a12;
  --bg-2: #122a1c;
  --panel: rgba(20, 40, 28, 0.82);
  --panel-solid: #14281c;
  --line: rgba(120, 200, 150, 0.16);
  --text: #e8f3ec;
  --muted: #9dbaa8;
  --green: #43c07a;
  --green-dark: #2e9d5f;
  --danger: #e2685f;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(67, 192, 122, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(46, 157, 95, 0.12), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg-2) 70%, #0b1710);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 18px 48px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--green), var(--green-dark));
  color: #06210f;
  font-size: 18px;
}
.brand-text { font-weight: 700; letter-spacing: .02em; }
.topbar-right { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

/* 卡片 */
.content { flex: 1; display: flex; flex-direction: column; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(12px);
}
.card.center {
  margin: auto;
  max-width: 460px;
  text-align: center;
}
.card h2 { margin: 0 0 10px; font-size: 20px; }
.muted { color: var(--muted); margin: 0 0 18px; line-height: 1.7; }
.muted strong { color: var(--text); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: .15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); text-decoration: none; }
.btn.primary {
  background: linear-gradient(140deg, var(--green), var(--green-dark));
  border-color: transparent;
  color: #06210f;
  font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* 认领 */
.claim-row { display: flex; align-items: stretch; gap: 8px; margin-bottom: 10px; }
.input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.input:focus { border-color: var(--green); }
.suffix {
  display: grid; place-items: center;
  padding: 0 14px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.actions { display: flex; gap: 10px; }
.status { margin: 14px 0 0; font-size: 13.5px; }
.status.error { color: var(--danger); }
.status.ok { color: var(--green); }

/* 邮箱主界面 */
.mail-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  min-height: 0;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(12px);
}
.account-label { font-size: 12px; color: var(--muted); }
.account-address { font-weight: 700; word-break: break-all; margin: 4px 0 2px; }
.account-name { font-size: 12.5px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); }
.nav-item.active { background: rgba(67, 192, 122, 0.16); border-color: rgba(67, 192, 122, 0.35); }
.nav-item span { width: 16px; text-align: center; color: var(--green); }
.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.text-btn {
  background: none; border: none; padding: 4px 0;
  color: var(--muted); font-size: 12.5px; font-family: inherit;
  text-align: left; cursor: pointer;
}
.text-btn:hover { color: var(--text); text-decoration: none; }

/* 内容面板 */
.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(12px);
  min-height: 380px;
}
.pane h3 { margin: 0 0 16px; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--muted); }

/* 写信：仿 163 的富文本编辑器（只留常用按钮） */
.editor-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 11px 11px 0 0;
  background: rgba(0, 0, 0, 0.22);
}
.tool {
  min-width: 30px;
  height: 28px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.tool:hover { background: rgba(255, 255, 255, 0.1); }
.tool-sep { width: 1px; height: 18px; margin: 0 6px; background: var(--line); }
.tool-colors { display: inline-flex; align-items: center; gap: 5px; }
.swatch {
  width: 16px; height: 16px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  cursor: pointer;
}
.swatch:hover { transform: scale(1.15); }
.editor {
  min-height: 240px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 0 0 11px 11px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  outline: none;
  overflow-wrap: break-word;
}
.editor:focus { border-color: var(--green); }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor ul, .editor ol { margin: 8px 0; padding-left: 26px; }
.editor a { color: var(--green); }
.editor + .actions { margin-top: 14px; }

.msg-list { display: flex; flex-direction: column; }
.msg-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 10px;
}
.msg-row:hover { background: rgba(255, 255, 255, 0.05); }
.msg-from { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg-subject { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-subject.unread { color: var(--text); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

.detail-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 16px; }
.detail-subject { font-size: 18px; font-weight: 700; margin-bottom: 8px; word-break: break-word; }
.detail-meta { font-size: 12.5px; color: var(--muted); line-height: 1.7; word-break: break-all; }
.detail-toggle { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.detail-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  font-size: 14px;
}
.detail-body img { max-width: 100%; height: auto; }

/* markdown 正文：跟着站点的暗色主题走，不再是一块白底 */
.detail-body.markdown { white-space: normal; }
.detail-body.markdown > :first-child { margin-top: 0; }
.detail-body.markdown > :last-child { margin-bottom: 0; }
.detail-body.markdown p { margin: 0 0 12px; }
.detail-body.markdown h1,
.detail-body.markdown h2,
.detail-body.markdown h3,
.detail-body.markdown h4,
.detail-body.markdown h5,
.detail-body.markdown h6 {
  margin: 20px 0 10px;
  line-height: 1.4;
}
.detail-body.markdown h1 { font-size: 20px; }
.detail-body.markdown h2 { font-size: 18px; }
.detail-body.markdown h3 { font-size: 16px; }
.detail-body.markdown h4,
.detail-body.markdown h5,
.detail-body.markdown h6 { font-size: 14.5px; }
.detail-body.markdown ul,
.detail-body.markdown ol { margin: 0 0 12px; padding-left: 24px; }
.detail-body.markdown li { margin: 4px 0; }
.detail-body.markdown li > ul,
.detail-body.markdown li > ol { margin: 4px 0 0; }
.detail-body.markdown blockquote {
  margin: 0 0 12px;
  padding: 6px 14px;
  border-left: 3px solid var(--green);
  background: rgba(67, 192, 122, 0.08);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}
.detail-body.markdown pre {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  overflow-x: auto;
}
.detail-body.markdown code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.32);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.detail-body.markdown pre code { padding: 0; background: none; }
.detail-body.markdown hr { margin: 18px 0; border: none; border-top: 1px solid var(--line); }
.detail-body.markdown a { color: var(--green); word-break: break-all; }
.detail-body.markdown del { color: var(--muted); }

/* HTML 邮件的原始排版：iframe 隔离脚本，但不再撑出一个突兀的大白框 */
.mail-frame {
  display: block;
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.attachments { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.attachments h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.attach-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  margin-bottom: 8px; font-size: 13px;
}
.attach-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-btn { margin-bottom: 14px; }

/* 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #14281c;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 13.5px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  z-index: 50;
  max-width: calc(100vw - 40px);
}
.toast.error { border-left-color: var(--danger); }

@media (max-width: 760px) {
  .page { padding: 14px 12px 32px; }
  .mail-layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
  .sidebar .nav { flex-direction: row; flex: 1; }
  .sidebar-foot { margin: 0; flex-direction: row; border: none; padding: 0; width: 100%; }
  .account { width: 100%; }
  .pane { min-height: 300px; padding: 18px; }
}