:root {
  --bg: #0b1020;
  --bg-soft: #121a30;
  --card: #161f38;
  --line: #26314f;
  --text: #e8edf9;
  --muted: #93a0bd;
  --accent: #4f8cff;
  --ok: #37d399;
  --danger: #ff6b6b;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: rgba(11, 16, 32, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: 0.2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }

main { padding: 14px 14px 40px; max-width: 720px; margin: 0 auto; overflow-x: hidden; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }

.address-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; min-width: 0; }
.address {
  flex: 1 1 0;
  min-width: 0;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 17px;
  font-weight: 600;
  word-break: break-all;
  color: #fff;
}

.hint { color: var(--muted); font-size: 12px; margin-top: 6px; min-height: 18px; }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

button {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #1c2743;
  color: var(--text);
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: default; }

.primary {
  flex: 1 1 180px;
  background: linear-gradient(135deg, #4f8cff, #7a5cff);
  border: none;
  color: #fff;
  font-weight: 600;
}
.ghost { background: transparent; }
.small { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.icon-btn { padding: 8px 12px; font-size: 13px; background: transparent; }
.back { margin-bottom: 12px; }

.list-head { display: flex; align-items: center; justify-content: space-between; }
.pill {
  background: #1e2a48;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
}

.mail-list { margin-top: 8px; display: flex; flex-direction: column; }
.mail-item {
  padding: 12px 10px;
  border-radius: 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.mail-item:last-child { border-bottom: none; }
.mail-item:hover { background: rgba(79, 140, 255, 0.07); }

.mail-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.mail-subject { font-weight: 600; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-preview { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(55, 211, 153, 0.15); color: var(--ok); margin-right: 6px; }

.empty { color: var(--muted); text-align: center; padding: 26px 0; font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #1a2440;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  cursor: pointer;
}

.subject { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.meta { color: var(--muted); font-size: 12px; word-break: break-all; }

.otp-box {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid rgba(79, 140, 255, 0.35);
}
.otp { font-family: ui-monospace, monospace; font-size: 24px; letter-spacing: 4px; font-weight: 700; }

.body-card { padding: 0; overflow: hidden; }
.mail-body { padding: 16px; word-break: break-word; }
.mail-body pre { white-space: pre-wrap; font: inherit; margin: 0; }
.mail-body iframe { width: 100%; border: none; min-height: 380px; background: #fff; border-radius: 12px; }

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  padding: 18px;
  width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h3 { margin: 0 0 14px; font-size: 16px; }

.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.field > span { display: block; margin-bottom: 6px; }
.field input[type="text"], .field input[type="password"], .field input:not([type]) {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1730;
  color: var(--text);
  font: inherit;
}
.field.row { display: flex; align-items: center; gap: 8px; }
.field.row > span { margin: 0; }

.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #223058;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --bg-soft: #ffffff;
    --card: #ffffff;
    --line: #dde3ef;
    --text: #12182a;
    --muted: #6b7690;
  }
  .topbar { background: rgba(244, 246, 251, 0.88); }
  .address { color: #12182a; }
  button { background: #eef2fb; }
  .primary { background: linear-gradient(135deg, #4f8cff, #7a5cff); }
  .chip, .pill { background: #eef2fb; }
}
