:root {
  --bg: #0f1412;
  --panel: #171e1b;
  --line: #2a3530;
  --text: #e8efe9;
  --muted: #8fa096;
  --accent: #3d9a6a;
  --accent-2: #2f7a54;
  --danger: #c45c5c;
  --warn: #c9a227;
  --radius: 14px;
  --font: "Segoe UI", "PT Root UI", "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 500px at 10% -10%, #1d3a2c 0%, transparent 55%),
    radial-gradient(700px 400px at 100% 0%, #243028 0%, transparent 50%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }
.muted, .link-muted { color: var(--muted); }
.link { color: var(--accent); }
.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 0.4rem;
}
.who { color: var(--muted); font-size: 0.9rem; word-break: break-all; }

.flash-wrap {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  display: grid;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}
.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #223028;
  border: 1px solid var(--line);
}
.flash--error { border-color: var(--danger); color: #ffd5d5; }
.flash--ok { border-color: var(--accent); }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: min(420px, 100%);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.75rem;
  backdrop-filter: blur(8px);
}
.auth-card h1 { margin: 0.2rem 0 0.4rem; font-size: 1.6rem; }

.stack { display: grid; gap: 0.9rem; margin-top: 1.2rem; }
label { display: grid; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #101613;
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
}
textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: #ffbdbd;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.side {
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.folders { display: grid; gap: 0.25rem; margin-top: 0.5rem; }
.folders a {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
}
.folders a.is-active,
.folders a:hover {
  background: #1f2a24;
  color: var(--text);
}
.main { padding: 1.25rem 1.5rem 2rem; }
.main-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.main-head h1 { margin: 0; font-size: 1.35rem; }
.empty { color: var(--muted); }

.mail-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.mail-list li { border-bottom: 1px solid var(--line); }
.mail-list a {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr auto;
  grid-template-areas:
    "from date"
    "subj subj"
    "preview preview";
  gap: 0.15rem 1rem;
  padding: 0.85rem 0.35rem;
}
.mail-list a:hover { background: #141b17; }
.from { grid-area: from; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date { grid-area: date; color: var(--muted); font-size: 0.85rem; justify-self: end; }
.subj { grid-area: subj; }
.preview { grid-area: preview; color: var(--muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg header { margin-bottom: 1rem; }
.msg h1 { margin: 0 0 0.75rem; font-size: 1.45rem; }
.msg p { margin: 0.25rem 0; color: var(--muted); }
.msg p strong { color: var(--text); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }
.msg-body {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101613;
  overflow: hidden;
}
.msg-body pre {
  margin: 0;
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}
.html-frame {
  width: 100%;
  min-height: 420px;
  border: 0;
  background: #fff;
}

.compose { max-width: 720px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .mail-list a {
    grid-template-columns: 1fr auto;
  }
}
