:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --border: #d2d2d7;
  --text: #1d1d1f;
  --sub: #6e6e73;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --red: #ff3b30;
  --green: #34c759;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
nav {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.nav-logo span { color: var(--blue); }
.main { max-width: 860px; margin: 0 auto; padding: 40px 20px 80px; }
.hero { text-align: center; margin-bottom: 36px; }
.hero h1 { font-size: 42px; font-weight: 700; letter-spacing: -1px; line-height: 1.1; margin-bottom: 10px; }
.hero p { font-size: 17px; color: var(--sub); }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 20px;
}
.email-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.email-display {
  flex: 1;
  min-width: 220px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s;
  user-select: all;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-display:hover { border-color: var(--blue); }
.email-display.empty { color: var(--sub); font-weight: 400; }
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-secondary { background: #e8e8ed; color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #dddde2; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.key-box {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
}
.key-label { font-size: 13px; color: var(--sub); }
.key-box code {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  flex: 1;
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 17px; font-weight: 600; }
.refresh-info { font-size: 13px; color: var(--sub); display: flex; align-items: center; gap: 8px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--blue); }
.msg-list { list-style: none; }
.msg-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.msg-item:last-child { border-bottom: none; }
.msg-item:hover { background: var(--bg); }
.msg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex-shrink: 0; }
.msg-dot.read { background: transparent; border: 1.5px solid var(--border); }
.msg-body { flex: 1; min-width: 0; }
.msg-from { font-size: 14px; font-weight: 600; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-subject { font-size: 14px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { font-size: 13px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 12px; color: var(--sub); text-align: right; flex-shrink: 0; padding-top: 2px; }
.empty-state { text-align: center; padding: 48px 0; color: var(--sub); }
.empty-state svg { margin-bottom: 16px; opacity: 0.35; }
.empty-state p { font-size: 15px; }
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1d1d1f;
  color: #fff;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn { from { opacity:0; transform: scale(0.95); } to { opacity:1; transform: scale(1); } }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.modal-subject { font-size: 17px; font-weight: 600; line-height: 1.3; }
.modal-meta { font-size: 13px; color: var(--sub); margin-top: 4px; }
.modal-close {
  background: var(--bg);
  border: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  transition: background 0.2s;
}
.modal-close:hover { background: var(--border); }
.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.modal-body iframe {
  width: 100%;
  border: none;
  min-height: 300px;
}
.key-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.key-input:focus { border-color: var(--blue); }
@media (max-width: 600px) {
  .hero h1 { font-size: 30px; }
  .card { padding: 20px 16px; }
  .email-bar { flex-direction: column; align-items: stretch; }
  .email-display { min-width: unset; }
}
