:root {
  --purple: #6a4df4;
  --purple-dark: #5939e0;
  --ink: #1f2430;
  --muted: #8a8fa3;
  --line: #e8eaf1;
  --bg: #ffffff;
  --soft: #f6f7fb;
  --danger: #e5484d;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

/* ---------- top bar ---------- */
.topbar {
  background: var(--purple);
  color: #fff;
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
}
.brand-icon { font-size: 22px; }
.brand-name b { font-weight: 800; }
.version {
  font-size: 12px;
  opacity: .75;
  border: 1px solid rgba(255,255,255,.4);
  padding: 2px 8px;
  border-radius: 20px;
}

/* ---------- layout ---------- */
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 40px;
}
.hero { text-align: center; padding: 44px 0 10px; }
.hero h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 8px;
}
.subtitle { color: var(--muted); margin: 0 0 26px; font-size: 15px; }

/* ---------- email box ---------- */
.email-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 6px 6px 16px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(31,36,48,.05);
  max-width: 520px;
  margin: 0 auto;
}
.email-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--ink);
  background: transparent;
  min-width: 0;
}
.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  padding: 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--soft); color: var(--ink); }

/* ---------- pills ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 18px 0 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  padding: 7px 12px;
  border-radius: 20px;
  cursor: pointer;
}
.pill:hover { background: var(--soft); }
.pill:disabled { opacity: .45; cursor: default; }
.pill.small { font-size: 13px; padding: 6px 10px; }
.pill.danger { color: var(--danger); }

/* ---------- inbox ---------- */
.inbox-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 26px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 10px rgba(31,36,48,.04);
}
.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 16px; }
.tab {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  padding: 4px 2px;
  border-bottom: 2px solid var(--ink);
}
.mail-list { min-height: 0; }
.mail-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: #fff;
  border-left: none; border-right: none; border-top: none;
  font: inherit;
  color: inherit;
}
.mail-item:last-child { border-bottom: none; }
.mail-item:hover { background: var(--soft); }
.mail-item.unread { background: #faf9ff; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.mail-main { flex: 1; min-width: 0; }
.mail-from { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.mail-subject { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-snippet { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.mail-time { font-size: 12px; color: var(--muted); flex-shrink: 0; margin-top: 2px; }

.empty { text-align: center; padding: 70px 20px; }
.empty-spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--muted);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-title { font-weight: 700; margin: 0 0 4px; font-size: 15px; }
.empty-sub { color: var(--muted); margin: 0; font-size: 13.5px; }

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

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,22,35,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal.wide { max-width: 640px; max-height: 85vh; display: flex; flex-direction: column; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal-sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.modal-row input {
  width: 100%;
  font-size: 15px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.modal-row input:focus { border-color: var(--purple); }
.modal-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn {
  border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-dark); }
.btn.ghost { background: var(--soft); color: var(--ink); }
.danger-text { color: var(--danger) !important; }

.mail-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mail-meta { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.mail-body {
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  min-height: 120px;
  white-space: pre-wrap;
  word-break: break-word;
}
.mail-body iframe { width: 100%; min-height: 320px; border: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }

@media (max-width: 520px) {
  .hero h1 { font-size: 27px; }
  .brand-name { font-size: 17px; }
}
