:root {
  --bg: #0b0f1a;
  --bg-2: #111726;
  --panel: rgba(23, 30, 48, 0.72);
  --panel-solid: #171e30;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ecf5;
  --muted: #93a0bb;
  --accent: #6d8cff;
  --accent-2: #a06bff;
  --green: #35d07f;
  --danger: #ff5d6c;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(1200px 700px at 70% -10%, #1a2440 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(500px 300px at 15% 20%, rgba(109, 140, 255, 0.16), transparent 70%),
    radial-gradient(500px 320px at 85% 70%, rgba(160, 107, 255, 0.14), transparent 70%);
  z-index: 0;
}

/* Header ------------------------------------------------------------------ */
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.brand-mark { font-size: 1.4rem; }
.header-actions { display: flex; align-items: center; gap: 12px; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--green);
  background: rgba(53, 208, 127, 0.1);
  border: 1px solid rgba(53, 208, 127, 0.3);
  padding: 5px 11px;
  border-radius: 999px;
}
.live-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(53, 208, 127, 0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(53, 208, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0); }
}

/* Buttons ----------------------------------------------------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  color: var(--text);
  background: transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 8px 13px; font-size: 0.82rem; border-radius: 9px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 26px rgba(109, 140, 255, 0.32);
}
.btn-primary:hover { opacity: 0.94; }
.btn-secondary { background: rgba(255,255,255,0.06); border-color: var(--border-strong); }
.btn-secondary:hover { background: rgba(255,255,255,0.11); }
.btn-ghost { color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-icon { padding: 11px 13px; background: rgba(255,255,255,0.06); border-color: var(--border-strong); }
.btn-danger { background: rgba(255, 93, 108, 0.12); border-color: rgba(255, 93, 108, 0.4); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 93, 108, 0.2); }
.link-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font: inherit; font-size: 0.88rem; padding: 6px; margin-top: 14px;
}
.link-btn:hover { text-decoration: underline; }

/* Landing ----------------------------------------------------------------- */
#app { position: relative; z-index: 1; flex: 1; display: flex; }

.landing {
  margin: auto;
  width: 100%;
  max-width: 640px;
  padding: 42px 22px 64px;
  text-align: center;
  animation: fade 0.4s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.landing h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #fff, #9fb2e8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle { color: var(--muted); margin: 0 0 30px; font-size: 1.02rem; }
.subtitle strong { color: var(--text); }

.address-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.address-row { display: flex; gap: 10px; }
.address-input {
  flex: 1;
  font: inherit;
  font-size: 1.02rem;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  padding: 13px 15px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: rgba(0,0,0,0.28);
  color: var(--text);
  min-width: 0;
}
.address-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.address-actions { display: flex; gap: 10px; margin-top: 12px; }
.address-actions .btn { flex: 1; }

.claim-box { display: flex; gap: 10px; margin-top: 14px; }
.claim-box .address-input { font-size: 0.92rem; }

.features {
  list-style: none;
  padding: 0;
  margin: 34px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 560px;
}
.features li {
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
}

.error-text { color: var(--danger); font-size: 0.85rem; margin: 12px 0 0; }

/* Inbox layout ------------------------------------------------------------ */
.inbox-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px;
  animation: fade 0.35s ease;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 130px);
  position: sticky;
  top: 22px;
}

.address-box {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.address-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.address-display {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.98rem;
  word-break: break-all;
  margin: 7px 0 12px;
  color: #cfe0ff;
}
.sidebar-actions { display: flex; gap: 8px; }
.sidebar-actions .btn { flex: none; }
.role-note {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #ffcf7a;
  background: rgba(255, 207, 122, 0.1);
  border: 1px solid rgba(255, 207, 122, 0.25);
  border-radius: 9px;
  padding: 8px 11px;
}

.list-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 16px 4px 10px;
}
.count {
  background: rgba(255,255,255,0.08); border-radius: 999px;
  padding: 2px 10px; font-size: 0.78rem; color: var(--text);
}

.message-list { overflow-y: auto; flex: 1; margin: 0 -6px; padding: 0 6px; }

.message-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: background 0.13s ease, border-color 0.13s ease;
  position: relative;
}
.message-item:hover { background: rgba(255,255,255,0.07); }
.message-item.active { border-color: var(--accent); background: rgba(109, 140, 255, 0.12); }
.message-item.unread::before {
  content: ""; position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.message-item.unread { padding-left: 20px; }
.mi-top { display: flex; justify-content: space-between; gap: 8px; }
.mi-from { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-time { font-size: 0.72rem; color: var(--muted); flex: none; }
.mi-subject { font-size: 0.85rem; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-snippet { font-size: 0.78rem; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-clip { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

.empty-state, .reader-empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
}
.empty-emoji { font-size: 2.4rem; margin-bottom: 8px; opacity: 0.8; }
.empty-state p, .reader-empty p { margin: 6px 0; font-size: 0.9rem; }
.empty-state small { font-size: 0.78rem; opacity: 0.8; }

#delete-inbox-btn { margin-top: 12px; width: 100%; }

/* Reader ------------------------------------------------------------------ */
.reader {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 130px);
  max-height: calc(100vh - 130px);
  overflow: hidden;
}
.reader-empty { margin: auto; }

.reader-content { overflow-y: auto; padding: 24px 26px; }
.reader-head { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 18px; }
.reader-subject { font-size: 1.28rem; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.01em; }
.reader-meta { display: grid; gap: 5px; font-size: 0.85rem; color: var(--muted); }
.reader-meta b { color: var(--text); font-weight: 600; }
.reader-toolbar { display: flex; gap: 9px; margin-top: 16px; flex-wrap: wrap; }

.attachments { margin-top: 20px; }
.attachments h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 10px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 13px; margin: 0 8px 8px 0;
  color: var(--text); text-decoration: none; font-size: 0.84rem;
}
.attachment-chip:hover { background: rgba(255,255,255,0.1); }
.attachment-chip small { color: var(--muted); }

.mail-body { margin-top: 6px; }
.mail-body iframe {
  width: 100%; border: 0; border-radius: 12px; background: #fff;
  min-height: 400px;
}
.mail-text {
  white-space: pre-wrap; word-wrap: break-word;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.88rem; line-height: 1.6; color: #dbe3f4;
  background: rgba(0,0,0,0.22); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}

/* Toast ------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  color: var(--text); padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow); z-index: 50; opacity: 0; transition: opacity 0.2s, transform 0.2s;
  font-size: 0.88rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal ------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 8, 16, 0.66);
  backdrop-filter: blur(4px); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 26px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; font-size: 1.15rem; }
.modal p { color: var(--muted); font-size: 0.88rem; margin: 0 0 16px; line-height: 1.5; }
.modal .address-input { width: 100%; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 860px) {
  .inbox-layout { grid-template-columns: 1fr; padding: 14px; }
  .sidebar { position: static; max-height: none; }
  .reader { min-height: 460px; max-height: none; }
  .site-header { padding: 14px 16px; }
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.24); }
