:root {
  --bg: #f3f4f6;
  --card: #fff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d4ed8;
  --danger: #b91c1c;
  --unread: #eff6ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 system-ui, Segoe UI, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; flex: 1; }
.brand a { color: inherit; }
.who { color: var(--muted); }
button.link, button.danger, button[type=submit] {
  font: inherit;
  cursor: pointer;
}
button.link {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
}
body.auth {
  display: grid;
  place-items: center;
}
.login { width: min(360px, calc(100vw - 2rem)); }
.login h1 { margin: 0 0 .25rem; font-size: 1.35rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
label { display: block; margin: 0.85rem 0; font-weight: 600; }
input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
button[type=submit] {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.inbox, .message { max-width: 960px; margin: 0 auto; padding: 1rem; }
.empty { color: var(--muted); padding: 2rem; text-align: center; }
.mail-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mail-list li { border-top: 1px solid var(--line); }
.mail-list li:first-child { border-top: 0; }
.mail-list li.unread { background: var(--unread); font-weight: 600; }
.mail-list a {
  display: grid;
  grid-template-columns: minmax(8rem, 16rem) minmax(10rem, 1fr) 8rem;
  grid-template-areas: "from subject date" "from snippet date";
  gap: 0.15rem 1rem;
  padding: 0.8rem 1rem;
  color: inherit;
  text-decoration: none;
}
.mail-list a:hover { background: #f8fafc; }
.from { grid-area: from; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject { grid-area: subject; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet { grid-area: snippet; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date { grid-area: date; color: var(--muted); font-weight: 400; text-align: right; }
.pager { display: flex; justify-content: space-between; margin: 1rem 0; }
.message .meta {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}
.message h1 { margin: 0 0 0.75rem; font-size: 1.3rem; }
dl { display: grid; grid-template-columns: 4rem 1fr; gap: 0.25rem 0.75rem; margin: 0 0 0.75rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
button.danger {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  width: auto;
}
.atts { list-style: none; padding: 0.75rem 0; }
.body, .body-text {
  margin-top: 1rem;
  width: 100%;
  min-height: 50vh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.body { border: 0; min-height: 60vh; }
.body-text { padding: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .mail-list a {
    grid-template-columns: 1fr auto;
    grid-template-areas: "from date" "subject subject" "snippet snippet";
  }
}
