:root {
  --bg: #0e0f12;
  --bg-2: #15171c;
  --bg-3: #1c1e24;
  --line: #2a2d34;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #a8c7fa;
  --unread: #d3e3fd;
  --danger: #f28b82;
  --ok: #81c995;
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; color: inherit; }
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 400px at 50% -10%, #1b2434, transparent 60%),
    var(--bg);
}
.login-card, .compose-card {
  width: min(420px, 92vw);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 22px;
  display: grid;
  gap: 12px;
}
.brand { font-weight: 650; letter-spacing: .04em; font-size: 22px; }
.brand span { color: var(--muted); font-weight: 500; }
.login-lead { margin: 0 0 8px; color: var(--muted); }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: #5f7aa8; }
button {
  border: 0;
  background: var(--accent);
  color: #0b1220;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 650;
  cursor: pointer;
}
.ghost, .text-btn, .icon-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.text-btn { border: 0; color: var(--muted); padding: 6px 0; }
.icon-btn {
  width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
}
.error { color: var(--danger); margin: 0; font-size: 13px; }
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 220px 360px 1fr;
}
.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  gap: 8px;
}
.side-brand { padding: 4px 10px 12px; }
.compose-btn { width: 100%; }
.folders { display: grid; gap: 2px; margin-top: 8px; }
.folder {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  text-align: left;
  font-weight: 500;
}
.folder:hover, .folder.active { background: var(--bg-3); }
.folder.active { color: var(--unread); }
.badge {
  min-width: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--accent);
}
.side-foot { margin-top: auto; padding: 10px 8px 4px; }
.who { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 4px; }
.list-pane {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}
.list-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.list-head h1 { margin: 0; font-size: 16px; grid-column: 1 / -1; }
#search { grid-column: 1 / 2; }
.list { overflow: auto; flex: 1; }
.row {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--bg-2); }
.row.active { background: var(--bg-3); }
.row.unread .from, .row.unread .subject { font-weight: 700; color: #fff; }
.from-line, .meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.subject { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.read-pane { min-width: 0; display: flex; flex-direction: column; background: #121317; }
.empty-read, .empty-list {
  margin: auto;
  color: var(--muted);
  padding: 24px;
}
.read-head { padding: 20px 24px 12px; border-bottom: 1px solid var(--line); }
.read-head h2 { margin: 0 0 10px; font-size: 22px; font-weight: 600; }
.read-actions { display: flex; gap: 8px; margin-top: 12px; }
.read-actions button { padding: 8px 14px; }
.addrs { color: var(--muted); font-size: 13px; line-height: 1.5; }
.body {
  flex: 1;
  border: 0;
  width: 100%;
  background: #fff;
}
.plain-body {
  padding: 20px 24px;
  white-space: pre-wrap;
  line-height: 1.6;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  z-index: 20;
}
.compose-card { width: min(640px, 94vw); }
.compose-card header { display: flex; justify-content: space-between; align-items: center; }
.compose-card textarea { resize: vertical; min-height: 180px; }
.compose-card footer { display: flex; gap: 8px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .list-pane { border-right: 0; }
  .read-pane:not(.open) { display: none; }
  .read-pane.open { position: fixed; inset: 0; z-index: 10; }
}
