:root {
  --bg: #eef1f7;
  --card: #ffffff;
  --primary: #5b5bd6;
  --primary-dark: #4f46e5;
  --text: #111827;
  --muted: #6b7280;
  --border: #e6e8f0;
  --danger: #e11d48;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hero { text-align: center; padding: 28px 16px 10px; }
.logo {
  width: 52px; height: 52px; margin: 0 auto 12px; color: #fff;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px rgba(99, 102, 241, .35);
}
.logo svg { width: 28px; height: 28px; }
.hero h1 { margin: 0; font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.hero .subtitle { margin: 8px auto 0; max-width: 520px; color: var(--muted); font-size: .95rem; line-height: 1.5; }

.container { max-width: 720px; margin: 0 auto; padding: 12px 16px 40px; }

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

.address-card { padding: 18px 16px; }
.address-line { text-align: center; }
.address { font-size: 1.15rem; font-weight: 700; letter-spacing: .01em; word-break: break-all; color: var(--text); }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 64px; padding: 9px 10px;
  background: #f4f5fb; border: 1px solid var(--border); border-radius: 10px;
  color: #3f4358; font-size: .72rem; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { background: #eceef9; border-color: #d6d9f0; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }

.inbox-card { margin-top: 16px; overflow: hidden; }
.inbox-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; border: none; padding: 13px 14px;
  font-size: .95rem; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
#btn-refresh { flex-direction: row; gap: 6px; min-width: 0; background: transparent; border: none; color: var(--primary); }
#btn-refresh svg { width: 18px; height: 18px; }

.inbox-body { min-height: 240px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border: 4px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .9s linear infinite;
}
.spinner.slow { animation-duration: 2.8s; }
.empty-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text); }
.empty-sub { margin: 6px 0 0; font-size: .88rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.mail-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.mail-item:last-child { border-bottom: none; }
.star { background: transparent; border: none; font-size: 1.1rem; color: #c7cbd6; cursor: pointer; padding: 2px; }
.star.on { color: #f59e0b; }
.mail-main { flex: 1; min-width: 0; cursor: pointer; }
.mail-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-sender { font-weight: 700; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.mail-subject { color: var(--muted); font-size: .85rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-del { background: transparent; border: none; cursor: pointer; opacity: .45; font-size: 1rem; }
.mail-del:hover { opacity: 1; }

.mail-detail { padding: 16px; text-align: left; }
.back { background: transparent; border: none; color: var(--primary); font-weight: 700; cursor: pointer; padding: 0; margin-bottom: 12px; }
.detail-subject { margin: 0 0 6px; font-size: 1.2rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.detail-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.detail-actions .btn { flex-direction: row; }
.mail-body { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mail-frame { width: 100%; height: 420px; border: none; background: #fff; }
.mail-text { margin: 0; padding: 14px; white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: .9rem; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { background: #f4f5fb; border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: .8rem; color: var(--muted); }

.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal h2 { margin: 0 0 6px; font-size: 1.15rem; }
.field { display: flex; align-items: center; margin: 14px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.field input { flex: 1; border: none; padding: 12px; font-size: .95rem; outline: none; min-width: 0; }
.field .suffix { padding: 0 12px; color: var(--muted); font-size: .9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .btn { flex-direction: row; min-width: 0; }

.dropdown { position: fixed; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 60; min-width: 160px; overflow: hidden; }
.menu-item { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 11px 14px; font-size: .9rem; cursor: pointer; color: var(--text); }
.menu-item:hover { background: #f4f5fb; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .88rem; z-index: 100; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }

.hidden { display: none !important; }
.muted { color: var(--muted); }

@media (max-width: 480px) {
  .hero h1 { font-size: 1.3rem; }
  .address { font-size: 1rem; }
  .actions { gap: 6px; }
  .btn { min-width: 56px; padding: 8px 6px; }
  .mail-frame { height: 360px; }
}
