:root {
  --bg: #0f1220;
  --panel: #181c2e;
  --panel-2: #1f2440;
  --line: #2a3050;
  --text: #e7e9f3;
  --muted: #9aa0c0;
  --accent: #6c8cff;
  --accent-2: #4cd6b4;
  --danger: #ff6b81;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #232a52 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.topbar { padding: 22px 20px 6px; text-align: center; }
.brand { font-size: 28px; font-weight: 800; letter-spacing: .5px; }
.tagline { color: var(--muted); margin-top: 6px; font-size: 14px; max-width: 640px; margin-inline: auto; }

.addr-card {
  max-width: 880px;
  margin: 18px auto 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.addr-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.addr-input {
  flex: 1 1 160px;
  min-width: 120px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
  outline: none;
}
.addr-input:focus { border-color: var(--accent); }
.addr-domain { color: var(--accent-2); font-weight: 600; font-size: 16px; white-space: nowrap; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b0e1a; font-weight: 700; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-small { padding: 4px 10px; font-size: 16px; line-height: 1; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

.layout {
  max-width: 1100px;
  margin: 14px auto;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
  min-height: 60vh;
}

.inbox, .reader {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.inbox { display: flex; flex-direction: column; }
.inbox-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.inbox-actions { display: flex; gap: 6px; }

.msg-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.msg-item {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .12s;
}
.msg-item:hover { background: var(--panel-2); }
.msg-item.active { background: var(--panel-2); border-left: 3px solid var(--accent); }
.msg-from { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.msg-time { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.msg-subject { font-size: 14px; margin-top: 2px; }
.msg-snippet { color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-badge { color: var(--accent-2); font-size: 12px; }

.empty, .reader-placeholder {
  color: var(--muted); text-align: center; padding: 40px 20px; font-size: 14px;
}

.reader { padding: 0; }
.reader-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.reader-subject { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.reader-meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.reader-meta b { color: var(--text); font-weight: 600; }
.reader-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.reader-body { padding: 0; }
.reader-body iframe { width: 100%; border: 0; min-height: 50vh; background: #fff; }
.reader-text { white-space: pre-wrap; word-wrap: break-word; padding: 18px; font-size: 14px; line-height: 1.6; }
.attachments { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; }
.att {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; text-decoration: none; color: var(--text);
}
.att:hover { border-color: var(--accent); }
.att.disabled { opacity: .5; pointer-events: none; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--accent-2); color: #07140f; padding: 10px 16px;
  border-radius: 10px; font-size: 14px; font-weight: 600;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .reader { min-height: 40vh; }
}
