Dough Git

commit

Whelp

commit
a47eb53327ebbdfb2ac2d73a214f05e4771c013e
author
Clove Twilight <[email protected]>
date
2026-08-30 23:44

diff --git a/lib/owners.ts b/lib/owners.ts
index aa0eaf8..3330797 100644
--- a/lib/owners.ts
+++ b/lib/owners.ts
@@ -170,9 +170,27 @@ export async function unassignAddress(username: string, address: string): Promis
   return dashboardState();
 }
 
+/**
+ * Remove a user entirely: drop their reservations and any admin rights. Their
+ * automatic username@domain stops being owned (mail to it falls to the
+ * catch-all). The caller is responsible for their stored mail beforehand.
+ * Refuses to remove the catch-all owner, since unrouted mail would be lost.
+ */
+export async function deleteUser(username: string): Promise<OwnersState> {
+  const s = state();
+  const u = username.toLowerCase();
+  if (!u) throw new Error("No user specified");
+  if (u === s.catchAll) throw new Error("Can't delete the catch-all owner");
+  delete s.owners[u];
+  s.admins = s.admins.filter((a) => a !== u);
+  await save();
+  return dashboardState();
+}
+
 export interface OwnersUser {
   username: string;
   isAdmin: boolean;
+  isCatchAll: boolean;
   auto: string;
   reserved: string[];
   addresses: string[];
@@ -188,6 +206,7 @@ export function dashboardState(): OwnersState {
   const users = knownUsers().map((u) => ({
     username: u,
     isAdmin: s.admins.includes(u),
+    isCatchAll: u === s.catchAll,
     auto: autoAddress(u),
     reserved: (s.owners[u] ?? []).map(expand),
     addresses: addressesFor(u),
diff --git a/lib/store.ts b/lib/store.ts
index 026a862..88377d6 100644
--- a/lib/store.ts
+++ b/lib/store.ts
@@ -222,3 +222,11 @@ export async function deleteByThreadKey(threadKey: string): Promise<StoredEmail[
   );
   return records.map(toEmail);
 }
+
+// Every message (inbox, sent, drafts) belonging to one mailbox user. Used by the
+// admin "delete user" flow, which wipes a user's mail before removing the user.
+export async function deleteByOwner(owner: string): Promise<StoredEmail[]> {
+  const metas = await listEmails(undefined, owner);
+  const removed = await Promise.all(metas.map((m) => deleteEmail(m.id)));
+  return removed.filter((r): r is StoredEmail => r !== null);
+}
diff --git a/public/settings.html b/public/settings.html
index 9d1a675..f732881 100644
--- a/public/settings.html
+++ b/public/settings.html
@@ -42,21 +42,25 @@
         </ul>
       </section>
 
-      <!-- Address reservations (admin only) -->
+      <!-- User management (admin only) -->
       <section class="settings-card hidden" id="ownersCard">
-        <h2>Address reservations</h2>
+        <h2>Users</h2>
         <p class="settings-hint">
-          Reserve extra addresses for a user. Each user always keeps their own
-          <code>[email protected]</code>. Unreserved mail goes to the
-          catch-all owner.
+          One card per user. Expand a card to see their info, reserve or remove
+          extra addresses, or delete the account. Everyone always keeps their own
+          <code>[email protected]</code>; unreserved mail goes to the
+          catch-all owner (<span id="catchAllName" class="mono">…</span>).
         </p>
 
-        <div id="ownersList" class="from-list"><span class="muted">Loading…</span></div>
+        <div id="ownersList" class="user-list"><span class="muted">Loading…</span></div>
 
-        <form id="assignForm" class="add-from">
-          <input id="assignUser" type="text" placeholder="username (e.g. clove)" autocomplete="off" />
-          <input id="assignAddr" type="text" placeholder="address or local-part (e.g. ctf)" autocomplete="off" />
-          <button type="submit" class="btn-accent">Reserve</button>
+        <form id="assignForm" class="add-user">
+          <h3>Reserve an address</h3>
+          <div class="add-user-row">
+            <input id="assignUser" type="text" placeholder="username (e.g. clove)" autocomplete="off" />
+            <input id="assignAddr" type="text" placeholder="address or local-part (e.g. ctf)" autocomplete="off" />
+            <button type="submit" class="btn-accent">Reserve</button>
+          </div>
         </form>
         <p id="ownersError" class="error hidden"></p>
       </section>
@@ -81,6 +85,22 @@
     </main>
   </div>
 
+  <div id="deleteUserModal" class="modal hidden">
+    <div class="compose confirm-card">
+      <h2>Delete user</h2>
+      <p class="settings-hint" id="deleteUserWarning"></p>
+      <label>
+        Type <span class="mono" id="deleteUserName">username</span> to confirm
+        <input id="deleteUserInput" type="text" autocomplete="off" autocapitalize="none" spellcheck="false" />
+      </label>
+      <p id="deleteUserError" class="error hidden"></p>
+      <div class="actions">
+        <button type="button" id="deleteUserCancel" class="btn-ghost">Cancel</button>
+        <button type="button" id="deleteUserConfirm" class="btn-danger" disabled>Delete user</button>
+      </div>
+    </div>
+  </div>
+
   <script src="/settings.js"></script>
   <script src="/sfx.js"></script>
 </body>
diff --git a/public/settings.js b/public/settings.js
index 4421ac2..3595cce 100644
--- a/public/settings.js
+++ b/public/settings.js
@@ -7,14 +7,24 @@
 
 const fromListEl = document.getElementById("fromList");
 
-// Admin reservations panel
+// Admin user-management panel
 const ownersCard = document.getElementById("ownersCard");
 const ownersListEl = document.getElementById("ownersList");
+const catchAllNameEl = document.getElementById("catchAllName");
 const assignForm = document.getElementById("assignForm");
 const assignUser = document.getElementById("assignUser");
 const assignAddr = document.getElementById("assignAddr");
 const ownersError = document.getElementById("ownersError");
 
+// Delete-user confirm modal
+const deleteUserModal = document.getElementById("deleteUserModal");
+const deleteUserWarning = document.getElementById("deleteUserWarning");
+const deleteUserNameEl = document.getElementById("deleteUserName");
+const deleteUserInput = document.getElementById("deleteUserInput");
+const deleteUserError = document.getElementById("deleteUserError");
+const deleteUserConfirm = document.getElementById("deleteUserConfirm");
+const deleteUserCancel = document.getElementById("deleteUserCancel");
+
 const pushStatusEl = document.getElementById("pushStatus");
 const pushToggleBtn = document.getElementById("pushToggleBtn");
 const pushTestBtn = document.getElementById("pushTestBtn");
@@ -55,39 +65,136 @@ async function loadSettings() {
   renderFromList(await res.json());
 }
 
-// --- Address reservations (admin only) ---
+// --- User management (admin only) ---
+
+// Which user cards are expanded, kept across re-renders.
+const expandedUsers = new Set();
+// The username the delete-confirm modal is currently armed for.
+let deleteTarget = null;
 
 function showOwnersError(msg) {
   ownersError.textContent = msg;
   ownersError.classList.remove("hidden");
 }
 
-function renderOwners(state) {
-  const users = state.users || [];
-  ownersListEl.innerHTML = users
-    .map((u) => {
-      const auto = `<span class="from-addr" title="Automatic — can't be removed">${escapeHtml(u.auto)}</span>`;
-      const extras = (u.reserved || [])
+function plural(n, word) {
+  return `${n} ${word}${n === 1 ? "" : "s"}`;
+}
+
+function summaryLine(u) {
+  const addrs = plural((u.addresses || []).length, "address");
+  const mail = plural(u.mailCount ?? 0, "message");
+  return `${addrs} · ${mail}`;
+}
+
+function userCardHtml(u, me) {
+  const isSelf = u.username === me;
+  const open = expandedUsers.has(u.username);
+
+  const badges = [
+    u.isAdmin ? '<span class="tag tag-admin">admin</span>' : "",
+    u.isCatchAll ? '<span class="tag tag-catchall">catch-all</span>' : "",
+    isSelf ? '<span class="tag tag-you">you</span>' : "",
+  ].join("");
+
+  const reservedChips = (u.reserved || []).length
+    ? (u.reserved || [])
         .map(
           (addr) => `
-            <span class="from-addr">
-              ${escapeHtml(addr)}
-              <button class="btn-ghost owner-remove" data-user="${escapeHtml(u.username)}" data-addr="${escapeHtml(addr)}">✕</button>
-            </span>`,
+          <span class="addr-chip">
+            <span class="mono">${escapeHtml(addr)}</span>
+            <button class="chip-x owner-remove" data-user="${escapeHtml(u.username)}" data-addr="${escapeHtml(addr)}" title="Remove reservation" aria-label="Remove ${escapeHtml(addr)}">✕</button>
+          </span>`,
         )
-        .join("");
-      const badge = u.isAdmin ? ' <span class="muted">(admin — sees all)</span>' : "";
-      return `
-        <div class="from-row" style="flex-direction:column;align-items:flex-start;gap:4px">
-          <strong>${escapeHtml(u.username)}${badge}</strong>
-          <div style="display:flex;flex-wrap:wrap;gap:6px">${auto}${extras}</div>
-        </div>`;
-    })
-    .join("");
+        .join("")
+    : '<span class="muted-inline">No reserved addresses.</span>';
+
+  // The catch-all owner and your own account can't be deleted.
+  const deleteBtn =
+    isSelf || u.isCatchAll
+      ? `<span class="muted-inline">${
+          isSelf ? "You can't delete your own account." : "The catch-all owner can't be deleted."
+        }</span>`
+      : `<button class="btn-danger user-delete" data-user="${escapeHtml(u.username)}">Delete user</button>`;
+
+  return `
+    <div class="user-card ${open ? "open" : ""}" data-user="${escapeHtml(u.username)}">
+      <button class="user-head" data-toggle="${escapeHtml(u.username)}" aria-expanded="${open}">
+        <span class="user-caret" aria-hidden="true">▸</span>
+        <span class="user-name mono">${escapeHtml(u.username)}</span>
+        <span class="user-badges">${badges}</span>
+        <span class="user-summary">${summaryLine(u)}</span>
+      </button>
+
+      <div class="user-body">
+        <dl class="user-info">
+          <dt>Automatic address</dt>
+          <dd><span class="mono">${escapeHtml(u.auto)}</span> <span class="muted-inline">(always owned)</span></dd>
+          <dt>Can send as</dt>
+          <dd>${(u.addresses || []).map((a) => `<span class="mono">${escapeHtml(a)}</span>`).join(", ")}</dd>
+          <dt>Stored mail</dt>
+          <dd>${plural(u.mailCount ?? 0, "message")}${u.isAdmin ? ' <span class="muted-inline">(admins also see every mailbox)</span>' : ""}</dd>
+        </dl>
+
+        <div class="user-section">
+          <h4>Reserved addresses</h4>
+          <div class="addr-chips">${reservedChips}</div>
+          <form class="reserve-inline" data-user="${escapeHtml(u.username)}">
+            <input type="text" class="reserve-addr" placeholder="address or local-part (e.g. ctf)" autocomplete="off" />
+            <button type="submit" class="btn-ghost">Reserve</button>
+          </form>
+        </div>
+
+        <div class="user-section user-danger">
+          <h4>Danger zone</h4>
+          <p class="muted-inline">
+            Deleting a user permanently removes all their stored mail and clears
+            their reservations and admin rights. They can sign in again and come
+            back as an ordinary user.
+          </p>
+          ${deleteBtn}
+        </div>
+      </div>
+    </div>`;
+}
+
+function renderOwners(state) {
+  const users = state.users || [];
+  const me = state.me || null;
+  catchAllNameEl.textContent = state.catchAll || "—";
+
+  ownersListEl.innerHTML = users.map((u) => userCardHtml(u, me)).join("");
+
+  ownersListEl.querySelectorAll(".user-head").forEach((btn) => {
+    btn.addEventListener("click", () => {
+      const name = btn.dataset.toggle;
+      if (expandedUsers.has(name)) expandedUsers.delete(name);
+      else expandedUsers.add(name);
+      const card = btn.closest(".user-card");
+      const nowOpen = expandedUsers.has(name);
+      card.classList.toggle("open", nowOpen);
+      btn.setAttribute("aria-expanded", String(nowOpen));
+    });
+  });
 
   ownersListEl.querySelectorAll(".owner-remove").forEach((btn) => {
     btn.addEventListener("click", () => unassign(btn.dataset.user, btn.dataset.addr));
   });
+
+  ownersListEl.querySelectorAll(".reserve-inline").forEach((form) => {
+    form.addEventListener("submit", (ev) => {
+      ev.preventDefault();
+      const addr = form.querySelector(".reserve-addr").value.trim();
+      if (addr) assign(form.dataset.user, addr);
+    });
+  });
+
+  ownersListEl.querySelectorAll(".user-delete").forEach((btn) => {
+    btn.addEventListener("click", () => {
+      const u = users.find((x) => x.username === btn.dataset.user);
+      openDeleteUser(btn.dataset.user, u ? u.mailCount ?? 0 : 0);
+    });
+  });
 }
 
 async function loadOwners() {
@@ -109,20 +216,74 @@ async function assign(username, address) {
     showOwnersError(data.error || "Couldn't reserve that address.");
     return;
   }
-  renderOwners(data);
+  // A freshly-reserved user is worth showing expanded.
+  expandedUsers.add(username.toLowerCase());
   assignUser.value = "";
   assignAddr.value = "";
+  await loadOwners();
 }
 
 async function unassign(username, address) {
+  ownersError.classList.add("hidden");
   const res = await fetch("/api/owners/unassign", {
     method: "POST",
     headers: { "Content-Type": "application/json" },
     body: JSON.stringify({ username, address }),
   });
-  if (res.ok) renderOwners(await res.json());
+  if (res.ok) await loadOwners();
 }
 
+// --- Delete user ---
+
+function openDeleteUser(username, mailCount) {
+  deleteTarget = username;
+  deleteUserNameEl.textContent = username;
+  deleteUserWarning.textContent =
+    `This permanently deletes ${plural(mailCount, "stored message")} for ` +
+    `“${username}” and clears their reservations and admin rights. This can't be undone.`;
+  deleteUserError.classList.add("hidden");
+  deleteUserInput.value = "";
+  deleteUserConfirm.disabled = true;
+  deleteUserModal.classList.remove("hidden");
+  deleteUserInput.focus();
+}
+
+function closeDeleteUser() {
+  deleteTarget = null;
+  deleteUserModal.classList.add("hidden");
+}
+
+deleteUserInput.addEventListener("input", () => {
+  deleteUserConfirm.disabled =
+    deleteUserInput.value.trim().toLowerCase() !== (deleteTarget || "").toLowerCase();
+});
+
+deleteUserCancel.addEventListener("click", closeDeleteUser);
+
+deleteUserModal.addEventListener("click", (ev) => {
+  if (ev.target === deleteUserModal) closeDeleteUser();
+});
+
+deleteUserConfirm.addEventListener("click", async () => {
+  if (!deleteTarget) return;
+  deleteUserConfirm.disabled = true;
+  const res = await fetch("/api/owners/delete-user", {
+    method: "POST",
+    headers: { "Content-Type": "application/json" },
+    body: JSON.stringify({ username: deleteTarget }),
+  });
+  const data = await res.json().catch(() => ({}));
+  if (!res.ok) {
+    deleteUserError.textContent = data.error || "Couldn't delete that user.";
+    deleteUserError.classList.remove("hidden");
+    deleteUserConfirm.disabled = false;
+    return;
+  }
+  expandedUsers.delete(deleteTarget);
+  closeDeleteUser();
+  await loadOwners();
+});
+
 assignForm.addEventListener("submit", (ev) => {
   ev.preventDefault();
   const u = assignUser.value.trim();
diff --git a/public/style.css b/public/style.css
index c2411f1..ba80417 100644
--- a/public/style.css
+++ b/public/style.css
@@ -41,12 +41,15 @@
 }
 
 :root {
-  /* Unified dark palette — derived from the info site's colours so every site
-     matches. bg #0a0b10, surface #12141c, surfaceHover #1b1e2a, text #f4f6fb,
-     muted #9aa3c2, border #232838, accent #f5a9b8. */
+  /* Unified dark palette — the same seven core colours the personal + info
+     sites use (bg #0a0b10, surface #12141c, surfaceHover #1b1e2a, text #f4f6fb,
+     muted #9aa3c2, border #232838, accent #f5a9b8), with a few derived shades.
+     The look is deliberately "terminal": square corners, hard offset shadows,
+     2px borders, uppercase tracked headings. */
   --base: #0a0b10;
   --mantle: #12141c;
   --crust: #05060a;
+  --raised: #0e1017;
   --surface0: #1b1e2a;
   --surface1: #232838;
   --surface2: #2c3346;
@@ -56,7 +59,15 @@
   --overlay0: #5b6480;
   --red: #d15f8c;
   --pink: #f5a9b8; /* accent */
+  --accent-alt: #d15f8c; /* headings, secondary accent */
   --yellow: #f5a9b8; /* warnings — kept on-palette */
+
+  --shadow-hard: 6px 6px 0 rgba(0, 0, 0, 0.38);
+  --shadow-hard-sm: 4px 4px 0 rgba(0, 0, 0, 0.38);
+}
+
+:root {
+  color-scheme: dark;
 }
 
 * {
@@ -65,13 +76,48 @@
 
 body {
   margin: 0;
-  background: var(--base);
+  background: linear-gradient(135deg, var(--base) 0%, var(--raised) 60%, var(--crust) 100%)
+    fixed;
   color: var(--text);
   font-family: "Comic Code", ui-monospace, monospace;
   font-size: 15px;
 }
 
+/* Background watermarks — ported from the personal site's base.css.ts so the
+   mailbox shares the same atmosphere. They sit at z-index 0 behind everything;
+   the opaque chrome panels (topbar, folder nav, list, cards) cover them, so in
+   practice they show through the reading pane and the settings page. */
+body::before {
+  content: "";
+  position: fixed;
+  inset: 0;
+  background: url("https://m.doughmination.gay/img/bg/estrogen.svg") center / cover no-repeat;
+  filter: invert(86%) sepia(8%) saturate(900%) hue-rotate(190deg) brightness(105%);
+  opacity: 0.05;
+  pointer-events: none;
+  z-index: 0;
+}
+
+body::after {
+  content: "";
+  position: fixed;
+  right: 0.5rem;
+  bottom: 0.5rem;
+  width: clamp(96px, 14vw, 168px);
+  aspect-ratio: 564 / 547;
+  background: url("https://m.doughmination.gay/img/bg/miku.png") center / contain no-repeat;
+  opacity: 0.18;
+  pointer-events: none;
+  z-index: 0;
+}
+
+.mono {
+  font-family: "Comic Code", ui-monospace, monospace;
+}
+
 .app {
+  position: relative;
+  z-index: 1;
   display: flex;
   flex-direction: column;
   height: 100vh;
@@ -83,13 +129,16 @@ body {
   justify-content: space-between;
   padding: 0.75rem 1.25rem;
   background: var(--mantle);
-  border-bottom: 1px solid var(--surface0);
+  border-bottom: 2px solid var(--surface1);
 }
 
 .topbar h1 {
-  font-size: 1.1rem;
+  font-size: 1.05rem;
   margin: 0;
-  font-weight: 600;
+  font-weight: 700;
+  text-transform: uppercase;
+  letter-spacing: 0.12em;
+  color: var(--text);
 }
 
 .topbar-right {
@@ -101,43 +150,51 @@ body {
 .layout {
   flex: 1;
   display: grid;
-  grid-template-columns: 140px 320px 1fr;
+  grid-template-columns: 150px 340px 1fr;
   overflow: hidden;
 }
 
 .folder-nav {
   display: flex;
   flex-direction: column;
-  gap: 0.15rem;
-  padding: 0.75rem 0.5rem;
+  gap: 0.25rem;
+  padding: 0.85rem 0.6rem;
   background: var(--crust);
-  border-right: 1px solid var(--surface0);
+  border-right: 2px solid var(--surface1);
 }
 
 .folder-item {
   background: transparent;
-  border: none;
+  border: 1px solid transparent;
+  border-radius: 0;
   color: var(--subtext1);
   text-align: left;
   padding: 0.5rem 0.75rem;
-  border-radius: 6px;
   font: inherit;
+  text-transform: uppercase;
+  letter-spacing: 0.06em;
+  font-size: 0.8rem;
   cursor: pointer;
+  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
 }
 
 .folder-item:hover {
   background: var(--surface0);
+  border-color: var(--surface2);
+  transform: translateX(2px);
 }
 
 .folder-item.active {
   background: var(--surface0);
   color: var(--text);
-  font-weight: 600;
+  font-weight: 700;
+  border-color: var(--pink);
+  border-left-width: 3px;
 }
 
 .list {
   overflow-y: auto;
-  border-right: 1px solid var(--surface0);
+  border-right: 2px solid var(--surface1);
   background: var(--mantle);
 }
 
@@ -146,8 +203,10 @@ body {
   align-items: center;
   gap: 0.5rem;
   padding: 0.85rem 1rem;
-  border-bottom: 1px solid var(--surface0);
+  border-bottom: 1px solid var(--surface1);
   cursor: pointer;
+  border-left: 3px solid transparent;
+  transition: background 0.12s ease, border-color 0.12s ease;
 }
 
 .list-item:hover {
@@ -181,11 +240,11 @@ body {
 
 .list-item.active {
   background: var(--surface0);
-  border-left: 3px solid var(--pink);
+  border-left-color: var(--pink);
 }
 
 .list-item .from {
-  font-weight: 600;
+  font-weight: 700;
   color: var(--text);
 }
 
@@ -199,6 +258,8 @@ body {
   color: var(--overlay0);
   font-size: 0.75rem;
   margin-top: 0.35rem;
+  text-transform: uppercase;
+  letter-spacing: 0.04em;
 }
 
 .detail {
@@ -217,7 +278,7 @@ body {
 }
 
 .detail .body {
-  border-top: 1px solid var(--surface0);
+  border-top: 2px solid var(--surface1);
   padding-top: 1.25rem;
   line-height: 1.6;
 }
@@ -257,10 +318,12 @@ body {
 }
 
 .message {
-  border: 1px solid var(--surface0);
-  border-radius: 8px;
+  border: 1px solid var(--surface2);
+  border-radius: 0;
   padding: 1rem 1.25rem;
   margin-bottom: 1rem;
+  background: var(--mantle);
+  box-shadow: var(--shadow-hard-sm);
 }
 
 .msg-head {
@@ -287,15 +350,17 @@ body {
 .dir-badge {
   font-size: 0.7rem;
   text-transform: uppercase;
-  letter-spacing: 0.03em;
+  letter-spacing: 0.06em;
   padding: 0.15rem 0.45rem;
-  border-radius: 4px;
+  border-radius: 0;
+  border: 1px solid var(--surface2);
   background: var(--surface1);
   color: var(--subtext1);
 }
 
 .dir-badge.outbound {
   background: var(--pink);
+  border-color: var(--pink);
   color: var(--crust);
 }
 
@@ -307,7 +372,7 @@ body {
 
 button {
   font: inherit;
-  border-radius: 6px;
+  border-radius: 0;
   padding: 0.5rem 1rem;
   border: 1px solid transparent;
   cursor: pointer;
@@ -321,21 +386,36 @@ a.btn-danger {
   align-items: center;
   justify-content: center;
   font: inherit;
-  border-radius: 6px;
+  border-radius: 0;
   padding: 0.5rem 1rem;
   border: 1px solid transparent;
   cursor: pointer;
   text-decoration: none;
 }
 
+.btn-accent,
+.btn-ghost,
+.btn-danger,
+a.btn-accent,
+a.btn-ghost,
+a.btn-danger {
+  text-transform: uppercase;
+  letter-spacing: 0.06em;
+  font-size: 0.82rem;
+  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease,
+    color 0.12s ease, filter 0.12s ease;
+}
+
 .btn-accent {
   background: var(--pink);
   color: var(--crust);
-  font-weight: 600;
+  border-color: var(--pink);
+  font-weight: 700;
 }
 
 .btn-accent:hover {
   filter: brightness(1.05);
+  transform: translateX(2px);
 }
 
 .btn-ghost {
@@ -346,23 +426,27 @@ a.btn-danger {
 
 .btn-ghost:hover {
   background: var(--surface0);
+  border-color: var(--pink);
+  transform: translateX(2px);
 }
 
 .btn-danger {
   background: transparent;
   border-color: var(--red);
   color: var(--red);
+  font-weight: 700;
 }
 
 .btn-danger:hover {
   background: var(--red);
   color: var(--crust);
+  transform: translateX(2px);
 }
 
 .modal {
   position: fixed;
   inset: 0;
-  background: rgba(17, 17, 27, 0.7);
+  background: rgba(5, 6, 10, 0.78);
   display: flex;
   align-items: center;
   justify-content: center;
@@ -374,25 +458,32 @@ a.btn-danger {
 
 .compose {
   background: var(--mantle);
-  border: 1px solid var(--surface0);
-  border-radius: 10px;
+  border: 2px solid var(--surface2);
+  border-radius: 0;
   padding: 1.5rem;
-  width: 420px;
+  width: 440px;
   max-width: 90vw;
   display: flex;
   flex-direction: column;
   gap: 0.75rem;
+  box-shadow: var(--shadow-hard);
 }
 
 .compose h2 {
   margin: 0 0 0.25rem 0;
+  text-transform: uppercase;
+  letter-spacing: 0.08em;
+  font-weight: 700;
+  color: var(--accent-alt);
 }
 
 .compose label {
   display: flex;
   flex-direction: column;
   gap: 0.35rem;
-  font-size: 0.85rem;
+  font-size: 0.8rem;
+  text-transform: uppercase;
+  letter-spacing: 0.05em;
   color: var(--subtext1);
 }
 
@@ -400,11 +491,13 @@ a.btn-danger {
 .compose textarea,
 .compose select {
   background: var(--surface0);
-  border: 1px solid var(--surface1);
-  border-radius: 6px;
+  border: 1px solid var(--surface2);
+  border-radius: 0;
   padding: 0.5rem 0.6rem;
   color: var(--text);
   font: inherit;
+  text-transform: none;
+  letter-spacing: normal;
   resize: vertical;
 }
 
@@ -454,7 +547,8 @@ a.btn-danger {
   align-items: center;
   gap: 0.5rem;
   background: var(--surface0);
-  border-radius: 6px;
+  border: 1px solid var(--surface2);
+  border-radius: 0;
   padding: 0.35rem 0.6rem;
   font-size: 0.85rem;
 }
@@ -486,9 +580,9 @@ a.btn-danger {
   display: block;
   width: 120px;
   height: 120px;
-  border-radius: 8px;
+  border-radius: 0;
   overflow: hidden;
-  border: 1px solid var(--surface1);
+  border: 1px solid var(--surface2);
   background: var(--surface0);
   cursor: zoom-in;
 }
@@ -508,7 +602,7 @@ a.btn-danger {
 .lightbox {
   position: fixed;
   inset: 0;
-  background: rgba(17, 17, 27, 0.9);
+  background: rgba(5, 6, 10, 0.92);
   display: flex;
   align-items: center;
   justify-content: center;
@@ -524,8 +618,9 @@ a.btn-danger {
 .lightbox img {
   max-width: 95vw;
   max-height: 95vh;
-  border-radius: 8px;
-  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
+  border-radius: 0;
+  border: 2px solid var(--surface2);
+  box-shadow: var(--shadow-hard);
 }
 
 .hidden {
@@ -543,6 +638,12 @@ a.btn-danger {
   position: static;
 }
 
+.login-card h2 {
+  text-transform: uppercase;
+  letter-spacing: 0.08em;
+  color: var(--accent-alt);
+}
+
 .hp-field {
   position: absolute;
   left: -9999px;
@@ -558,7 +659,9 @@ a.btn-danger {
   border: none;
   color: var(--pink);
   font: inherit;
-  font-weight: 600;
+  font-weight: 700;
+  text-transform: uppercase;
+  letter-spacing: 0.06em;
   padding: 0.25rem 0;
   margin-bottom: 0.75rem;
   cursor: pointer;
@@ -568,25 +671,30 @@ a.btn-danger {
 .settings-page {
   flex: 1;
   overflow-y: auto;
-  padding: 1.5rem;
+  padding: 1.75rem 1.5rem;
   display: flex;
   flex-direction: column;
   gap: 1.25rem;
-  max-width: 640px;
+  max-width: 720px;
   width: 100%;
   margin: 0 auto;
 }
 
 .settings-card {
   background: var(--mantle);
-  border: 1px solid var(--surface0);
-  border-radius: 10px;
+  border: 2px solid var(--surface2);
+  border-radius: 0;
   padding: 1.25rem 1.5rem;
+  box-shadow: var(--shadow-hard);
 }
 
 .settings-card h2 {
   margin: 0 0 0.35rem 0;
   font-size: 1rem;
+  text-transform: uppercase;
+  letter-spacing: 0.08em;
+  font-weight: 700;
+  color: var(--accent-alt);
 }
 
 .settings-hint {
@@ -596,6 +704,11 @@ a.btn-danger {
   line-height: 1.5;
 }
 
+.settings-hint code,
+.settings-hint .mono {
+  color: var(--subtext1);
+}
+
 .from-list {
   list-style: none;
   margin: 0 0 0.85rem 0;
@@ -610,8 +723,9 @@ a.btn-danger {
   align-items: center;
   gap: 0.6rem;
   background: var(--surface0);
-  border-radius: 6px;
-  padding: 0.4rem 0.6rem;
+  border: 1px solid var(--surface2);
+  border-radius: 0;
+  padding: 0.45rem 0.65rem;
 }
 
 .from-row .from-addr {
@@ -641,27 +755,246 @@ a.btn-danger {
   font-size: 0.8rem;
 }
 
-.add-from {
+/* ---------- Users panel (admin) ---------- */
+.user-list {
+  display: flex;
+  flex-direction: column;
+  gap: 0.6rem;
+  margin-bottom: 1rem;
+}
+
+.user-card {
+  border: 1px solid var(--surface2);
+  background: var(--surface0);
+}
+
+.user-card.open {
+  border-color: var(--pink);
+  box-shadow: var(--shadow-hard-sm);
+}
+
+.user-head {
+  width: 100%;
+  display: flex;
+  align-items: center;
+  gap: 0.6rem;
+  padding: 0.6rem 0.75rem;
+  background: transparent;
+  border: none;
+  color: var(--text);
+  text-align: left;
+  cursor: pointer;
+}
+
+.user-head:hover {
+  background: var(--surface1);
+}
+
+.user-caret {
+  color: var(--overlay0);
+  transition: transform 0.14s ease;
+}
+
+.user-card.open .user-caret {
+  transform: rotate(90deg);
+  color: var(--pink);
+}
+
+.user-name {
+  font-weight: 700;
+  letter-spacing: 0.02em;
+}
+
+.user-badges {
+  display: flex;
+  gap: 0.3rem;
+  flex-wrap: wrap;
+}
+
+.tag {
+  font-size: 0.62rem;
+  text-transform: uppercase;
+  letter-spacing: 0.08em;
+  font-weight: 700;
+  padding: 0.1rem 0.35rem;
+  border: 1px solid var(--surface2);
+  color: var(--subtext1);
+  background: var(--mantle);
+}
+
+.tag-admin {
+  border-color: var(--pink);
+  color: var(--pink);
+}
+
+.tag-catchall {
+  border-color: var(--accent-alt);
+  color: var(--accent-alt);
+}
+
+.tag-you {
+  border-color: var(--overlay0);
+  color: var(--overlay0);
+}
+
+.user-summary {
+  margin-left: auto;
+  font-size: 0.75rem;
+  color: var(--overlay0);
+  text-transform: uppercase;
+  letter-spacing: 0.04em;
+  white-space: nowrap;
+}
+
+.user-body {
+  display: none;
+  flex-direction: column;
+  gap: 1rem;
+  padding: 0.85rem 0.9rem 1rem;
+  border-top: 1px solid var(--surface2);
+}
+
+.user-card.open .user-body {
+  display: flex;
+}
+
+.user-info {
+  margin: 0;
+  display: grid;
+  grid-template-columns: max-content 1fr;
+  gap: 0.35rem 0.9rem;
+  font-size: 0.85rem;
+}
+
+.user-info dt {
+  color: var(--overlay0);
+  text-transform: uppercase;
+  letter-spacing: 0.05em;
+  font-size: 0.72rem;
+  padding-top: 0.1rem;
+}
+
+.user-info dd {
+  margin: 0;
+  color: var(--subtext1);
+  word-break: break-word;
+}
+
+.user-section h4 {
+  margin: 0 0 0.5rem 0;
+  font-size: 0.78rem;
+  text-transform: uppercase;
+  letter-spacing: 0.07em;
+  color: var(--accent-alt);
+}
+
+.addr-chips {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 0.4rem;
+  margin-bottom: 0.6rem;
+}
+
+.addr-chip {
+  display: inline-flex;
+  align-items: center;
+  gap: 0.4rem;
+  background: var(--mantle);
+  border: 1px solid var(--surface2);
+  padding: 0.25rem 0.2rem 0.25rem 0.5rem;
+  font-size: 0.82rem;
+}
+
+.chip-x {
+  background: transparent;
+  border: none;
+  color: var(--overlay0);
+  font-size: 0.8rem;
+  line-height: 1;
+  padding: 0.1rem 0.35rem;
+  cursor: pointer;
+}
+
+.chip-x:hover {
+  color: var(--red);
+}
+
+.reserve-inline {
+  display: flex;
+  gap: 0.4rem;
+}
+
+.reserve-inline input {
+  flex: 1;
+  min-width: 0;
+  background: var(--mantle);
+  border: 1px solid var(--surface2);
+  border-radius: 0;
+  padding: 0.45rem 0.6rem;
+  color: var(--text);
+  font: inherit;
+}
+
+.reserve-inline input:focus {
+  outline: 2px solid var(--pink);
+  outline-offset: 1px;
+}
+
+.user-danger {
+  border-top: 1px dashed var(--surface2);
+  padding-top: 0.85rem;
+}
+
+.user-danger p {
+  margin: 0 0 0.65rem 0;
+  line-height: 1.5;
+}
+
+/* ---------- Add-user / reserve form ---------- */
+.add-user h3 {
+  margin: 0 0 0.5rem 0;
+  font-size: 0.8rem;
+  text-transform: uppercase;
+  letter-spacing: 0.07em;
+  color: var(--accent-alt);
+}
+
+.add-from,
+.add-user-row {
   display: flex;
   gap: 0.5rem;
 }
 
-.add-from input {
+.add-from input,
+.add-user-row input {
   flex: 1;
   min-width: 0;
   background: var(--surface0);
-  border: 1px solid var(--surface1);
-  border-radius: 6px;
+  border: 1px solid var(--surface2);
+  border-radius: 0;
   padding: 0.5rem 0.6rem;
   color: var(--text);
   font: inherit;
 }
 
-.add-from input:focus {
+.add-from input:focus,
+.add-user-row input:focus {
   outline: 2px solid var(--pink);
   outline-offset: 1px;
 }
 
+/* ---------- Confirm modal ---------- */
+.confirm-card {
+  width: 460px;
+}
+
+.confirm-card label {
+  text-transform: none;
+  letter-spacing: normal;
+  font-size: 0.85rem;
+  color: var(--subtext1);
+}
+
 .push-status {
   font-size: 0.9rem;
   margin-bottom: 0.85rem;
@@ -698,9 +1031,9 @@ a.btn-danger {
   background: var(--surface1);
   color: var(--text);
   border: 1px solid var(--surface2);
-  border-radius: 8px;
+  border-radius: 0;
   padding: 0.6rem 0.9rem;
-  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
+  box-shadow: var(--shadow-hard-sm);
   font-size: 0.9rem;
   pointer-events: auto;
   animation: toast-in 0.16s ease;
@@ -715,7 +1048,9 @@ a.btn-danger {
   background: transparent;
   border: none;
   color: var(--pink);
-  font-weight: 600;
+  font-weight: 700;
+  text-transform: uppercase;
+  letter-spacing: 0.06em;
   padding: 0.1rem 0.3rem;
 }
 
@@ -769,7 +1104,7 @@ a.btn-danger {
     padding: 0.5rem;
     gap: 0.4rem;
     border-right: none;
-    border-bottom: 1px solid var(--surface0);
+    border-bottom: 2px solid var(--surface1);
     -webkit-overflow-scrolling: touch;
   }
 
@@ -817,7 +1152,10 @@ a.btn-danger {
     max-width: 100%;
     max-height: 92vh;
     overflow-y: auto;
-    border-radius: 14px 14px 0 0;
+  }
+
+  .confirm-card {
+    width: 100%;
   }
 
   .compose .actions {
@@ -844,11 +1182,27 @@ a.btn-danger {
 
   /* iOS Safari zooms in on focus if an input's font-size is under 16px */
   .compose input,
-  .compose textarea {
+  .compose textarea,
+  .reserve-inline input,
+  .add-user-row input,
+  .add-from input {
     font-size: 16px;
   }
 
+  .user-summary {
+    display: none;
+  }
+
+  .user-info {
+    grid-template-columns: 1fr;
+    gap: 0.15rem 0;
+  }
+
+  .user-info dd {
+    margin-bottom: 0.4rem;
+  }
+
   button {
     min-height: 40px;
   }
-}
\ No newline at end of file
+}
diff --git a/server.ts b/server.ts
index 4f5b1e9..16d2fcd 100644
--- a/server.ts
+++ b/server.ts
@@ -11,6 +11,7 @@ import {
   deleteDraft,
   deleteEmail,
   deleteByThreadKey,
+  deleteByOwner,
   type Folder,
   type StoredEmail,
   type StoredAttachment,
@@ -46,6 +47,7 @@ import {
   dashboardState,
   assignAddress,
   unassignAddress,
+  deleteUser,
   initOwners,
 } from "./lib/owners";
 import { bareAddress } from "./lib/settings";
@@ -680,9 +682,21 @@ app.get("/api/settings", (c) => {
   return c.json({ fromAddresses: addrs, defaultFrom: addrs[0] ?? null });
 });
 
-app.get("/api/owners", (c) => {
+app.get("/api/owners", async (c) => {
   if (!isAdmin(c.get("user"))) return c.json({ error: "Forbidden" }, 403);
-  return c.json(dashboardState());
+  const state = dashboardState();
+  // Tally stored mail per owner in one pass so the UI can show a count and warn
+  // before a delete (one scan, not one per user).
+  const counts = new Map<string, number>();
+  for (const e of await listEmails()) {
+    const k = (e.owner || "").toLowerCase();
+    counts.set(k, (counts.get(k) ?? 0) + 1);
+  }
+  const users = state.users.map((u) => ({
+    ...u,
+    mailCount: counts.get(u.username.toLowerCase()) ?? 0,
+  }));
+  return c.json({ ...state, users, me: c.get("user").toLowerCase() });
 });
 
 app.post("/api/owners/assign", async (c) => {
@@ -707,6 +721,31 @@ app.post("/api/owners/unassign", async (c) => {
   return c.json(await unassignAddress(String(body.username), String(body.address)));
 });
 
+// Remove a user: permanently delete all their stored mail (attachments too),
+// then drop their reservations and admin rights. They can sign in again via
+// PocketID and are recreated as an ordinary user owning just username@domain.
+app.post("/api/owners/delete-user", async (c) => {
+  const actor = c.get("user");
+  if (!isAdmin(actor)) return c.json({ error: "Forbidden" }, 403);
+
+  const body = await c.req.json().catch(() => null);
+  const username = String(body?.username ?? "").trim().toLowerCase();
+  if (!username) return c.json({ error: "username is required" }, 400);
+  if (username === actor.toLowerCase()) {
+    return c.json({ error: "You can't delete your own account." }, 400);
+  }
+
+  const removed = await deleteByOwner(username);
+  await purgeAttachmentFiles(removed);
+
+  try {
+    const state = await deleteUser(username);
+    return c.json({ ...state, deletedMail: removed.length });
+  } catch (err) {
+    return c.json({ error: (err as Error).message }, 400);
+  }
+});
+
 app.get("/api/push/status", async (c) =>
   c.json({
     configured: pushConfigured(),