:root {
  --bg: #f4f5f8;
  --bg-glow: rgba(79, 70, 229, 0.18);
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e6e8ee;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 18, 27, 0.04), 0 12px 32px rgba(16, 18, 27, 0.06);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --bg-glow: rgba(99, 102, 241, 0.22);
    --card: #171a21;
    --text: #e8eaf0;
    --muted: #9aa1af;
    --line: #262a34;
    --accent: #818cf8;
    --accent-dark: #a5b4fc;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei',
    'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.glow {
  position: fixed;
  inset: -20% 0 auto 0;
  height: 520px;
  background: radial-gradient(60% 60% at 50% 0%, var(--bg-glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 48px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.inbox-card {
  padding: 18px;
  margin-bottom: 16px;
}

.address-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.address-line code {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.status-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.spacer {
  flex: 1;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pill.danger {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}

.btn:hover {
  background: color-mix(in srgb, var(--text) 4%, var(--card));
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-outline {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.list-card {
  min-height: 220px;
  padding: 6px;
  overflow: hidden;
}

.message-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.message {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.message:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.message + .message {
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.m-from {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-time {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.m-subject {
  grid-column: 1 / -1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-preview {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message.unread .m-from,
.message.unread .m-subject {
  font-weight: 700;
}

.message.unread .m-subject::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  vertical-align: middle;
}

.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  font-size: 34px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.85;
}

.empty p {
  margin: 0;
}

.empty-hint {
  margin-top: 6px !important;
  font-size: 13px;
  opacity: 0.8;
}

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

/* ---- 详情 ---- */
.detail {
  width: min(860px, calc(100% - 24px));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.detail[open] {
  display: flex;
  flex-direction: column;
}

.detail::backdrop {
  background: rgba(10, 12, 18, 0.5);
  backdrop-filter: blur(2px);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.detail-title {
  flex: 1;
  min-width: 0;
}

.detail-title h2 {
  margin: 0 0 4px;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.detail-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.dot {
  margin: 0 6px;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
}

.detail-tools {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.detail-body {
  flex: 1;
  min-height: 280px;
  overflow: auto;
  background: #fff;
}

.detail-body iframe {
  display: block;
  width: 100%;
  height: min(58vh, 620px);
  border: 0;
  background: #fff;
}

.detail-body pre {
  margin: 0;
  padding: 18px 20px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: 14px;
  color: #16181d;
  background: #fff;
}

.attachments {
  padding: 12px 20px 18px;
  border-top: 1px solid var(--line);
}

.attachments h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.attachments ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachments a {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachments a:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.92);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  max-width: calc(100% - 40px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 560px) {
  .shell {
    padding: 32px 0 32px;
  }

  .hero h1 {
    font-size: 25px;
  }

  .address-line {
    flex-direction: column;
    align-items: stretch;
  }

  .address-line code {
    font-size: 14.5px;
  }

  .status-line .spacer {
    display: none;
  }
}
