:root {
  --bg: #0b1020;
  --bg2: #131a30;
  --bg3: #1b2440;
  --text: #e8ecf8;
  --muted: #8b94b3;
  --accent: #4f46e5;
  --accent2: #6366f1;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 1100px; margin: 0 auto; min-height: 100vh; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg2); border-radius: var(--radius); padding: 32px 28px;
  width: 100%; max-width: 360px; text-align: center;
  border: 1px solid rgba(255,255,255,.06);
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; margin: 0 auto 16px;
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.1);
  background: var(--bg); color: var(--text); font-size: 16px; margin-bottom: 12px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.btn {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.login-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; position: sticky; top: 0; z-index: 10;
  background: rgba(11,16,32,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar .logo {
  width: 38px; height: 38px; border-radius: 12px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px; flex-shrink: 0;
}
.topbar h1 { font-size: 17px; flex: 1; }
.topbar h1 small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.icon-btn {
  background: var(--bg3); border: none; color: var(--text); width: 38px; height: 38px;
  border-radius: 12px; font-size: 17px; cursor: pointer; flex-shrink: 0;
}
.searchbar { padding: 12px 16px 4px; }
.searchbar input {
  width: 100%; padding: 12px 14px 12px 40px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08); background: var(--bg2);
  color: var(--text); font-size: 14px; outline: none;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238b94b3' stroke-width='2'><circle cx='11' cy='11' r='7'/><path d='M21 21l-4.3-4.3'/></svg>");
  background-repeat: no-repeat; background-position: 13px center;
}

/* ---------- address list ---------- */
.addr-list { padding: 12px 16px 90px; display: flex; flex-direction: column; gap: 10px; }
.addr-card {
  background: var(--bg2); border-radius: var(--radius); padding: 14px;
  display: flex; align-items: center; gap: 13px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.05);
}
.addr-card:active { transform: scale(.99); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 800; color: #fff;
}
.addr-info { flex: 1; min-width: 0; }
.addr-info .email {
  font-size: 14.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.addr-info .sub { font-size: 12px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--bg3); color: var(--muted); font-size: 12.5px; font-weight: 700;
  min-width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0 8px; flex-shrink: 0;
}
.badge.unread { background: var(--accent); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }
.empty .big { font-size: 44px; margin-bottom: 12px; }

/* ---------- message list ---------- */
.msg-list { padding: 12px 16px 90px; display: flex; flex-direction: column; gap: 10px; }
.msg-card {
  background: var(--bg2); border-radius: var(--radius); padding: 14px;
  cursor: pointer; border: 1px solid rgba(255,255,255,.05);
}
.msg-card.unread { border-color: rgba(99,102,241,.5); }
.msg-card .from { font-size: 12px; color: var(--muted); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-card .subj { font-size: 14.5px; font-weight: 600; margin-bottom: 6px; }
.msg-card.unread .subj::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent2); margin-right: 8px; vertical-align: 1px;
}
.msg-card .meta { display: flex; align-items: center; gap: 10px; }
.msg-card .time { font-size: 11.5px; color: var(--muted); }
.otp-chip {
  background: rgba(34,197,94,.14); color: var(--green); border: 1px solid rgba(34,197,94,.35);
  font-size: 13px; font-weight: 800; letter-spacing: 2px;
  padding: 4px 12px; border-radius: 8px; cursor: pointer; font-family: monospace;
}

/* ---------- detail ---------- */
.detail { padding: 16px 16px 90px; }
.detail-card { background: var(--bg2); border-radius: var(--radius); padding: 18px; }
.detail-card .from { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.detail-card h2 { font-size: 17px; margin: 8px 0 4px; }
.detail-card .time { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.otp-big {
  background: rgba(34,197,94,.1); border: 1.5px dashed rgba(34,197,94,.5);
  border-radius: 14px; padding: 18px; text-align: center; margin-bottom: 16px; cursor: pointer;
}
.otp-big .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.otp-big .code {
  font-size: 38px; font-weight: 800; letter-spacing: 8px; color: var(--green);
  font-family: monospace; margin: 8px 0;
}
.otp-big .hint { font-size: 11px; color: var(--muted); }
.detail-body {
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border-radius: 12px; padding: 14px; max-height: 50vh; overflow: auto;
}
.detail-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn2 {
  flex: 1; padding: 12px; border-radius: 12px; border: none; font-size: 14px;
  font-weight: 700; cursor: pointer;
}
.btn2.primary { background: var(--accent); color: #fff; }
.btn2.danger { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.btn2.ghost { background: var(--bg3); color: var(--text); }

/* ---------- misc ---------- */
.back-btn { font-size: 22px; cursor: pointer; padding: 4px 8px; }
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #04120a; font-weight: 700; font-size: 13px;
  padding: 10px 20px; border-radius: 30px; opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 99;
}
.toast.show { opacity: 1; }
.section-title { padding: 14px 16px 2px; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; }
.del-addr {
  background: none; border: none; color: var(--muted); font-size: 18px;
  cursor: pointer; padding: 6px; flex-shrink: 0;
}
@media (min-width: 720px) {
  .addr-list, .msg-list, .detail { padding-left: 24px; padding-right: 24px; }
}
