:root {
  --void: #050505;
  --graphite: #121212;
  --panel: #161616;
  --cyan: #22f0ff;
  --cyan-dim: rgba(34, 240, 255, 0.16);
  --purple: #b44aff;
  --purple-dim: rgba(180, 74, 255, 0.2);
  --text: #f3f4f6;
  --muted: #8b8f98;
  --line: rgba(255, 255, 255, 0.08);
  --glass: rgba(18, 18, 18, 0.62);
  --danger: #ff4d6d;
  --radius: 22px;
  --gap: 14px;
  --sans: "Manrope", "Segoe UI", sans-serif;
  --display: "Syne", "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 500px at 8% -10%, rgba(180, 74, 255, 0.16), transparent 50%),
    radial-gradient(800px 480px at 110% 0%, rgba(34, 240, 255, 0.1), transparent 46%),
    var(--void);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.04em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cyan-dim), var(--purple-dim));
  border: 1px solid rgba(34, 240, 255, 0.35);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand small {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(440px, 100%);
  padding: 36px 32px;
  border-radius: 28px;
}
.gate-card h1 {
  font-family: var(--display);
  font-size: clamp(34px, 6vw, 48px);
  line-height: 0.95;
  margin: 22px 0 10px;
}
.gate-card .lede { color: var(--muted); margin: 0 0 28px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field textarea, .field select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
}
.field input:focus, .field textarea:focus {
  border-color: rgba(34, 240, 255, 0.55);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}
.flash { min-height: 20px; color: #ff8fab; font-size: 13px; margin: 0 0 8px; }

.btn {
  border: 0;
  border-radius: 14px;
  background: var(--cyan);
  color: #041016;
  padding: 12px 16px;
  font-weight: 700;
}
.btn:hover { filter: brightness(1.08); }
.btn.wide { width: 100%; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--danger); color: #fff; }
.btn.purple { background: var(--purple); color: #fff; }

.desk {
  min-height: 100vh;
  padding: var(--gap);
  display: grid;
  grid-template-columns: 260px minmax(300px, 380px) 1fr;
  gap: var(--gap);
}
.pane {
  min-width: 0;
  min-height: calc(100vh - var(--gap) * 2);
  border-radius: var(--radius);
  background: var(--graphite);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.nav-pane { padding: 18px 14px; }
.nav-pane .brand { margin: 4px 8px 22px; }
.compose-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 13px 14px;
  font-weight: 700;
  color: #041016;
  background: linear-gradient(135deg, var(--cyan), #7dfff0);
  box-shadow: 0 0 24px rgba(34, 240, 255, 0.28);
  margin-bottom: 18px;
}
.folders { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.folder {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #c9cdd4;
  text-align: left;
  padding: 10px 12px;
  border-radius: 14px;
}
.folder svg { width: 16px; height: 16px; opacity: 0.8; flex: 0 0 auto; }
.folder:hover { background: rgba(255, 255, 255, 0.04); }
.folder.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(34, 240, 255, 0.28);
}
.folder .count {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--purple);
  color: #fff;
  box-shadow: 0 0 12px rgba(180, 74, 255, 0.45);
}
.folder .count:empty { display: none; }
.who {
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.who strong { display: block; font-size: 14px; }
.who small { color: var(--muted); font-size: 11px; word-break: break-all; }
.who-actions { display: flex; gap: 8px; margin-top: 10px; }
.who-actions button {
  flex: 1;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 7px;
  font-size: 12px;
}

.list-head, .read-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.list-head h2, .read-head h2, .composer h2, .admin h2 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0 0 12px;
  font-size: 26px;
}
.search {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  border-radius: 14px;
  padding: 11px 12px;
  outline: none;
}
.search:focus { border-color: rgba(34, 240, 255, 0.45); }
.list { overflow: auto; flex: 1; padding: 8px; }
.row {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 12px;
  border-radius: 16px;
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
}
.row:hover, .row.active { background: rgba(255, 255, 255, 0.05); }
.row.active { box-shadow: inset 0 0 0 1px rgba(34, 240, 255, 0.22); }
.row.unread .from span { color: var(--text); font-weight: 700; }
.row .from {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #d5d8de;
}
.row time { color: var(--muted); font-size: 11px; }
.row .subject { font-size: 14px; }
.row .snippet {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty, .welcome {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 40px 24px;
}
.welcome h2 {
  font-family: var(--display);
  color: var(--text);
  margin: 0 0 8px;
}

.read-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.read-head .left, .read-head .right { display: flex; gap: 8px; flex-wrap: wrap; }
.letter { padding: 22px 24px 48px; overflow: auto; flex: 1; }
.letter-kicker { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.letter h1 {
  font-family: var(--display);
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: -0.04em;
  margin: 0 0 16px;
}
.people { display: grid; gap: 6px; margin-bottom: 22px; color: #c5c8cf; font-size: 13px; }
.people b { color: var(--cyan); font-weight: 700; }
.body-html, .body-text {
  font-size: 15.5px;
  line-height: 1.7;
  max-width: 72ch;
  color: #e8eaee;
}
.body-html img { max-width: 100%; height: auto; }
.attachments { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments a {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
}

.composer, .admin { padding: 22px 24px 40px; overflow: auto; flex: 1; }
.composer textarea { min-height: 260px; resize: vertical; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.stat b { display: block; font-family: var(--display); font-size: 28px; }
.stat span { color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.admin-section { margin-bottom: 28px; }
.admin-section h3 { margin: 0 0 12px; font-size: 15px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
  align-items: end;
}
.inline-form.quad { grid-template-columns: 1.3fr 1fr 90px auto; }
.dns {
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  color: #b8f7ff;
  font-size: 12px;
  overflow: auto;
}
.hp {
  position: absolute;
  left: -9999px;
  height: 0;
  overflow: hidden;
}
.receive-only {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.menu-btn {
  display: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
}

@media (max-width: 1100px) {
  .desk { grid-template-columns: 220px 1fr; }
  .read-pane { grid-column: 1 / -1; min-height: 48vh; }
}
@media (max-width: 800px) {
  .desk { grid-template-columns: 1fr; padding: 10px; }
  .pane { min-height: auto; }
  .nav-pane { display: none; }
  .nav-pane.open { display: flex; }
  .menu-btn { display: inline-flex; }
  .admin-grid, .inline-form, .inline-form.quad { grid-template-columns: 1fr; }
  .letter, .composer, .admin { padding: 16px; }
}
