:root {
  --bg: #12110f;
  --bg2: #1b1916;
  --card: #221f1b;
  --line: #3a342c;
  --ink: #f3eadc;
  --muted: #b5a894;
  --accent: #e2b657;
  --accent-dim: #8a6d28;
  --ok: #8fce7a;
  --err: #e07a6a;
  --unread: #7eb8e8;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
  background:
    radial-gradient(900px 400px at 10% -10%, #2a2318 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: var(--bg2);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
}
.brand { font-weight: 700; letter-spacing: .04em; margin-bottom: 4px; }
.brand small { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }
.nav { margin-top: 28px; display: flex; flex-direction: column; gap: 6px; }
.nav a, .folders a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
}
.nav a:hover, .folders a:hover, .nav a.active, .folders a.active {
  background: #2d2923;
  text-decoration: none;
}
.folders { margin-top: 24px; }
.folders h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.main { padding: 28px 32px 48px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
}
h1 { margin: 0; font-size: 22px; font-weight: 650; }
.muted { color: var(--muted); }

.flash { list-style: none; padding: 0; margin: 0 0 16px; }
.flash li {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.flash .ok { background: #1e2a1c; color: var(--ok); }
.flash .error { background: #2a1b19; color: var(--err); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 22px 1.2fr 2fr 140px;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.row:last-child { border-bottom: 0; }
a.row:hover { background: #2a2621; text-decoration: none; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; margin-top: 7px;
}
.dot.on { background: var(--unread); }
.row.unread { font-weight: 650; }
.from, .subject, .date { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date { color: var(--muted); text-align: right; font-size: 13px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-box {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}
.auth-box h1 { margin-bottom: 8px; }
label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 13px; }
input, select {
  width: 100%;
  background: #161410;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.btn {
  display: inline-block;
  border: 0;
  background: var(--accent);
  color: #1a1408;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.danger { background: #c45c4e; color: #fff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.form-row { display: flex; gap: 8px; margin: 12px 0 20px; }
.form-row input { flex: 1; }

.meta { color: var(--muted); line-height: 1.5; margin-bottom: 18px; }
.mail-body {
  background: #f7f1e5;
  color: #221c14;
  border-radius: 12px;
  padding: 18px;
  white-space: pre-wrap;
  overflow-x: auto;
}
.mail-html {
  background: #fff;
  color: #111;
  border-radius: 12px;
  padding: 8px;
  overflow: auto;
  max-width: 100%;
}
.alias-list { margin: 0; padding: 0; list-style: none; }
.alias-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
code { font-family: ui-monospace, Consolas, monospace; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .row { grid-template-columns: 22px 1fr; }
  .subject, .date { grid-column: 2; }
}
