/* HyperiaMail's style sheet, shared by the webmail and the dashboard.
 *
 * Deliberately plain for now (PLAN.md, Design kit): change the variables
 * below to restyle both apps. Pages only use the class names in this file.
 * Nothing is loaded from elsewhere: system fonts, no icon fonts.
 */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f1f3f8;
  --surface: #ffffff;
  --text: #1a2030;
  --muted: #667085;
  --border: #e3e7ee;
  /* A line that shows more: a field pointed at, a card lifted. */
  --border-strong: #cdd3de;
  --hover: #eff2f7;
  /* Pointed at, on the page's own colour instead of a surface. */
  --hover-strong: #e4e8f0;

  --accent: #2459d6;
  /* Where the main button's colour starts, above the accent. */
  --accent-from: #2f69e8;
  --accent-text: #ffffff;
  --accent-soft: #e8eefc;
  /* The glow round what has the keyboard, and under what's lifted. */
  --ring: 0 0 0 3px rgba(36, 89, 214, 0.18);
  --accent-glow: rgba(36, 89, 214, 0.19);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, 0.22);
  --danger: #c62828;
  --danger-soft: #fdecec;
  --ok: #2e7d32;
  --ok-soft: #e9f5ea;
  --warn: #8a5300;
  --warn-soft: #fff4e0;

  /* An unread conversation's row. */
  --unread: #fafbff;

  --radius: 10px;
  --radius-lg: 16px;
  /* How things move: quick for what's pointed at, smooth for what arrives. */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --quick: 140ms;
  --smooth: 260ms;
  --gap: 16px;
  --sidebar: 220px;
  --topbar: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}
html {
  /* Phones don't enlarge text on their own when turned sideways. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  /* 600 at most: hierarchy comes from size and colour, not weight. */
  font-weight: 600;
  line-height: 1.25;
}
b,
strong {
  font-weight: 600;
}
h1 {
  font-size: 22px;
}
h2 {
  font-size: 19px;
}
h3 {
  font-size: 16px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.center {
  text-align: center;
}
.mono {
  font-family: var(--mono);
}
.break {
  overflow-wrap: anywhere;
}

/* ---- Layout helpers ---------------------------------------------------- */

.stack > * + * {
  margin-top: var(--gap);
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.spacer {
  flex: 1;
}

/* ---- Sign-in pages ------------------------------------------------------ */

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-box {
  width: 100%;
  max-width: 400px;
}
.auth-box .card {
  padding: 28px;
}
.brand {
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.auth-box > .brand {
  display: block;
  text-align: center;
  margin-bottom: 20px;
}
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 20px 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

/* ---- App layout: top bar, side navigation, content --------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  /* Installed on a phone, the page reaches under the status bar and
     beside the notch; keep the bar's content clear of them. */
  height: calc(var(--topbar) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0
    max(20px, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .btn {
  white-space: nowrap;
}
.topbar-user {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-body {
  display: flex;
  align-items: flex-start;
}
.sidebar {
  position: sticky;
  top: var(--topbar);
  width: var(--sidebar);
  flex-shrink: 0;
  min-height: calc(100vh - var(--topbar));
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.main {
  flex: 1;
  min-width: 0;
  padding: 24px;
  max-width: 1100px;
}
.page-title {
  margin-bottom: 4px;
}
.page-head {
  margin-bottom: 20px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-heading {
  margin: 16px 8px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.nav-link:hover {
  background: var(--hover);
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
/* A count that isn't unread mail, such as drafts. */
/* The mailbox being worked in, for someone with a shared one to open. */
.nav-mailbox {
  margin-bottom: 10px;
  font-size: 13px;
}
/* A link to manage what the navigation lists, set back a little. */
.nav-link-quiet {
  color: var(--muted);
  font-size: 13px;
}
.nav-count-quiet {
  font-weight: 400;
}

/* Phones and narrow windows: the navigation becomes a row above the page. */
@media (max-width: 760px) {
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  /* The avatar says who's signed in; the address doesn't fit. */
  .topbar-user {
    display: none;
  }
  .app-body {
    display: block;
  }
  .sidebar {
    position: static;
    width: auto;
    min-height: 0;
    padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav {
    flex-direction: row;
  }
  .nav-heading {
    display: none;
  }
  .nav-link {
    white-space: nowrap;
    min-height: 40px;
  }
  .main {
    padding: 16px max(12px, env(safe-area-inset-right))
      calc(88px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
}

/* The webmail marks the page while the device is offline (pwa.js); the
   installed app then shows the mail it kept. */
[data-network="offline"] body::after {
  content: "You're offline.";
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  text-align: center;
}
[data-network="offline"][data-installed] body::after {
  content: "You're offline: showing the mail kept on this device.";
}

/* ---- Cards ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card {
  margin-top: var(--gap);
}
.card-flush {
  padding: 0;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2,
.card-head h3 {
  margin: 0;
}

/* ---- Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover {
  background: var(--hover);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover {
  background: var(--accent);
  filter: brightness(0.95);
}
.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-soft);
}
.btn-quiet {
  border-color: transparent;
  background: transparent;
}
.btn-small {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 13px;
}
/* The fields of a rule, side by side where there's room. */
.rule-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 14px;
  align-items: end;
}
.rule-check {
  min-height: 38px;
  margin-bottom: 14px;
}
/* "Move to…" beside the small buttons of an open conversation. */
.input-move {
  width: auto;
  max-width: 180px;
  min-height: 30px;
  padding: 3px 26px 3px 10px;
  font-size: 13px;
}
.btn-block {
  width: 100%;
}

/* ---- Forms ------------------------------------------------------------- */

.field {
  display: block;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
}
.input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
select.input {
  padding-right: 6px;
}
.input-code {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
}
.input-short {
  max-width: 260px;
}
.input-auto {
  width: auto;
}
textarea.input {
  min-height: 280px;
  resize: vertical;
  line-height: 1.5;
}
/* A signature: a few lines. */
textarea.input-signature {
  min-height: 110px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.hint {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

/* ---- Notices and badges ------------------------------------------------ */

.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: var(--gap);
}
.notice-error {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}
.notice-ok {
  background: var(--ok-soft);
  border-color: transparent;
  color: var(--ok);
}
.notice-warn {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}
.notice-info {
  background: var(--accent-soft);
  border-color: transparent;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---- Avatars ----------------------------------------------------------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.avatar-1 {
  background: #e8eefc;
  color: #2459d6;
}
.avatar-2 {
  background: #e9f5ea;
  color: #2e7d32;
}
.avatar-3 {
  background: #e6f4f8;
  color: #0e7490;
}
.avatar-4 {
  background: #fff4e0;
  color: #8a5300;
}
.avatar-5 {
  background: #fdecec;
  color: #c62828;
}

/* ---- Lists and tables -------------------------------------------------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list > li + li {
  border-top: 1px solid var(--border);
}
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.table tr:last-child td {
  border-bottom: 0;
}
/* Wide tables scroll sideways on small screens instead of the page. */
.scroll-x {
  overflow-x: auto;
}
/* Table cells: addresses and times stay on one line; long text wraps in a
   column wide enough to read. */
.nowrap {
  white-space: nowrap;
}
/* Text with line breaks of its own, such as an issue's details. */
.pre-line {
  white-space: pre-line;
}
.wide {
  min-width: 240px;
}
.medium {
  min-width: 140px;
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* ---- Dashboard: message trace ----------------------------------------- */

.trace + .trace {
  border-top: 1px solid var(--border);
}
.trace > summary {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.trace > summary::-webkit-details-marker {
  display: none;
}
.trace > summary:hover {
  background: var(--hover);
}
.trace-body {
  padding: 4px 16px 16px;
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0 0 8px;
  font-size: 14px;
}
.facts dt {
  color: var(--muted);
}
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---- Mail: message list ------------------------------------------------ */

/* A line under a folder's toolbar, such as when Trash empties itself. */
.folder-note {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.message-link {
  display: grid;
  grid-template-columns: 34px minmax(0, 200px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
}
.message-link:hover {
  background: var(--hover);
}
.message-from,
.message-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-preview {
  color: var(--muted);
}
.message-time {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.message.unread .message-from,
.message.unread .message-subject,
.message.unread .message-time {
  font-weight: 600;
  color: var(--text);
}
.message.unread {
  background: var(--unread);
}
@media (max-width: 760px) {
  .message-link {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas: "avatar from time" "avatar line line";
    row-gap: 2px;
  }
  .message-link .avatar {
    grid-area: avatar;
  }
  .message-from {
    grid-area: from;
  }
  .message-line {
    grid-area: line;
  }
  .message-time {
    grid-area: time;
  }
  .message-preview {
    display: none;
  }
}

/* How many messages a conversation has, after who wrote them. */
.message-count {
  color: var(--muted);
  font-weight: 400;
}
.message.unread .message-count {
  font-weight: 400;
}

/* ---- Mail: a conversation ---------------------------------------------- */

.thread-item + .thread-item {
  border-top: 1px solid var(--border);
}
/* A folded message: one line that opens it. */
.thread-fold {
  display: grid;
  grid-template-columns: 34px minmax(0, 200px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 4px;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.thread-fold:hover {
  background: var(--hover);
}
.thread-fold .message-from,
.thread-fold .message-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-item.unread .thread-fold .message-from {
  font-weight: 600;
}
.mail-head-fold {
  cursor: pointer;
}
.thread-actions {
  margin: 12px 0 16px;
}
@media (max-width: 760px) {
  .thread-fold {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    grid-template-areas: "avatar from time";
  }
  .thread-fold .avatar {
    grid-area: avatar;
  }
}

/* ---- Mail: one message ------------------------------------------------- */

.mail-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 16px 0;
}
.mail-who {
  flex: 1;
  min-width: 0;
}
.mail-frame {
  display: block;
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}
.mail-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.attachment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
}
a.attachment:hover {
  background: var(--hover);
}
/* Pictures sent as attachments, shown above the download list. */
.attachment-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
.attachment-preview {
  display: block;
  max-width: 100%;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--hover);
}
.attachment-preview.gone {
  display: none;
}
.attachment-preview img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  width: auto;
  height: auto;
}
/* A file input inside a button-looking label. */
.hidden-input {
  display: none;
}

/* ---- Settings ---------------------------------------------------------- */

.qr {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}
.secret {
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}
.setup {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
}

/* ---- Phones: overrides, last so they win ------------------------------ */

@media (max-width: 760px) {
  /* "New message" floats at the bottom right, within thumb's reach. */
  .nav .nav-write {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 20;
    width: auto;
    min-height: 52px;
    padding: 0 22px;
    border-radius: 999px;
    font-size: 15px;
    box-shadow: 0 4px 14px rgba(28, 34, 48, 0.25);
  }
  .nav .nav-write-hidden {
    display: none;
  }
  /* Text of 16px or more, so phones don't zoom in on a field. */
  .input {
    font-size: 16px;
  }
  .btn {
    min-height: 40px;
  }
  .mail-frame {
    height: 65vh;
  }
  /* Room for the offline bar below the floating button. */
  [data-network="offline"] .nav .nav-write {
    bottom: calc(52px + env(safe-area-inset-bottom));
  }
  /* A message's date goes under the sender, so the address fits. */
  .mail-head {
    flex-wrap: wrap;
    row-gap: 2px;
  }
  .mail-who {
    flex-basis: calc(100% - 46px);
  }
  .mail-head > :last-child {
    margin-left: 46px;
  }
}

/* ---- Webmail: the three-pane look ---------------------------------------
   An icon rail, the folder side bar, then the conversations beside the open
   one (PLAN.md, New look). Phones keep the top bar and the one-row folders,
   and show the list or the conversation, not both. */

.icon {
  flex-shrink: 0;
}
.nav-link .icon {
  color: var(--muted);
}
.nav-link.active .icon {
  color: inherit;
}
.btn-icon {
  padding: 3px 7px;
}
/* A toolbar button: an icon and a word, quiet until pointed at. */
.btn-tool {
  gap: 6px;
  border-color: transparent;
  background: transparent;
}
.btn-tool:hover {
  background: var(--hover);
}
.rail,
.side-account,
.fab,
.read-back {
  display: none;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 2px;
}
.list-title {
  margin: 0;
  font-size: 18px;
}
.list-pane .toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.list-pane .toolbar form {
  flex: 1;
  min-width: 0;
}
.list-pane .toolbar .input-short {
  width: 100%;
  max-width: none;
}
.list-paging {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px;
}
/* A conversation's row: who and when, the subject, then two lines of it. */
.list-pane .message-link {
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-areas: "avatar from time" "avatar subject subject" "avatar preview preview";
  align-items: start;
  row-gap: 1px;
  padding: 12px 14px;
}
.list-pane .message-link .avatar {
  grid-area: avatar;
  margin-top: 2px;
}
.list-pane .message-from {
  grid-area: from;
}
.list-pane .message-time {
  grid-area: time;
}
.list-pane .message-subject {
  grid-area: subject;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-pane .message-preview {
  grid-area: preview;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.4;
}
.message.open,
.message.open.unread {
  background: var(--accent-soft);
}
.message.open .message-link:hover {
  background: transparent;
}

.read-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.read-toolbar .spacer {
  flex: 1;
}
.read > *:not(.read-toolbar) {
  margin-left: 20px;
  margin-right: 20px;
}
.read {
  padding-bottom: 24px;
}
.read-title {
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 20px;
}
.read-empty {
  height: 100%;
  min-height: 240px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
}
.read-empty .icon {
  width: 40px;
  height: 40px;
}
.nav-link-phone {
  display: flex;
}

@media (min-width: 761px) {
  .app-mail {
    display: grid;
    grid-template-columns: 56px var(--sidebar) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .app-mail > .topbar {
    display: none;
  }
  .app-mail > .app-body {
    display: contents;
  }
  .rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .rail .spacer {
    flex: 1;
  }
  .rail-link {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--muted);
    cursor: pointer;
  }
  .rail-link:hover {
    background: var(--hover);
    color: var(--text);
  }
  .rail-link.active {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .app-mail .sidebar {
    position: static;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    padding: 12px 10px;
  }
  .side-account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }
  .side-address {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
  }
  /* Writing starts from the rail or the list's round button. */
  .app-mail .nav .nav-write,
  .app-mail .nav-link-phone {
    display: none;
  }
  .app-mail .main {
    max-width: none;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
  }
  .app-mail .main:not(.main-split) > * {
    max-width: 1000px;
  }
  .app-mail .main-split {
    padding: 0;
    overflow: hidden;
  }
  .split {
    display: grid;
    grid-template-columns: clamp(300px, 36%, 440px) minmax(0, 1fr);
    height: 100%;
  }
  .list-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .read-pane {
    min-height: 0;
    overflow-y: auto;
    background: var(--surface);
  }
  .fab {
    position: sticky;
    bottom: 16px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    margin: auto 16px 16px auto;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 4px 14px rgba(36, 89, 214, 0.35);
  }
  .fab .icon {
    width: 22px;
    height: 22px;
  }
}

/* A narrow reading pane keeps the toolbar on one line: icons, no words. */
.read-pane {
  container-type: inline-size;
}
@container (max-width: 700px) {
  .read-toolbar .btn-tool span {
    display: none;
  }
  .read-toolbar .btn-tool {
    min-width: 34px;
    justify-content: center;
  }
}
.read-toolbar .input-move {
  max-width: 130px;
}
/* The account at the top of the side bar: the address, or for someone with
   a shared mailbox, the chooser. */
.side-account .nav-mailbox {
  min-width: 0;
  margin: 0;
}

/* Narrower windows and phones: the list, or the open conversation. */
@media (max-width: 1000px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
  .split.has-open .list-pane,
  .split:not(.has-open) .read-pane {
    display: none;
  }
  .read-back {
    display: inline-flex;
  }
}
@media (max-width: 760px) {
  /* The chooser leads the row of folders. */
  .app-mail .sidebar {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .side-account.has-chooser {
    display: block;
    flex-shrink: 0;
  }
  .side-account.has-chooser .avatar {
    display: none;
  }
  .app-mail .main-split {
    padding: 0 0 calc(88px + env(safe-area-inset-bottom));
  }
  .list-pane,
  .read-pane {
    background: var(--surface);
  }
  .btn-tool span {
    display: none;
  }
  .read-toolbar .btn-tool {
    min-width: 40px;
    justify-content: center;
  }
  .read > *:not(.read-toolbar) {
    margin-left: 14px;
    margin-right: 14px;
  }
}

/* ---- Webmail: list details, picking conversations, the folder menu ------ */

/* A row's attached files: a paperclip by the sender, and their names. */
.message-clip {
  display: inline-flex;
  margin-left: 6px;
  vertical-align: -3px;
  color: var(--muted);
}
.message-clip .icon {
  width: 14px;
  height: 14px;
}
.list-pane .message-link {
  grid-template-areas: "avatar from time" "avatar subject subject" "avatar preview preview" "avatar chips chips";
}
.message-chips {
  grid-area: chips;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text);
}
.chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip .icon {
  width: 14px;
  height: 14px;
  color: var(--danger);
}

/* Picking: a box over the sender's picture, shown when pointed at or once
   anything is picked. */
.message {
  position: relative;
}
.message-pick {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  opacity: 0;
  cursor: pointer;
}
.message-pick input,
.pick-all {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.message:hover .message-pick,
.message.picked .message-pick,
.message-pick:focus-within {
  opacity: 1;
}
.message.picked {
  background: var(--accent-soft);
}
.pick-all {
  flex-shrink: 0;
  margin: 0 4px 0 6px;
}
.picked-count {
  font-weight: 600;
  white-space: nowrap;
}
/* While conversations are picked, their actions take the search's place. */
.toolbar.picking form,
.toolbar.picking > .btn[title="Refresh"] {
  display: none;
}
.toolbar .input-move {
  max-width: 120px;
}

/* A folder's menu: the dots at the end of its line, or a right click. */
.nav-more {
  display: none;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: -2px -4px -2px 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.nav-more:hover {
  background: var(--border);
  color: var(--text);
}
.menu-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.modal-backdrop {
  background: rgba(20, 26, 40, 0.35);
}
.menu {
  position: fixed;
  z-index: 41;
  min-width: 210px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(20, 26, 40, 0.16);
}
.menu-title {
  padding: 4px 10px 6px;
  font-size: 12px;
  color: var(--muted);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover {
  background: var(--hover);
}
.menu-item-danger {
  color: var(--danger);
}
.modal {
  position: fixed;
  z-index: 42;
  left: 50%;
  top: 22%;
  width: min(420px, calc(100vw - 24px));
  transform: translateX(-50%);
  box-shadow: 0 16px 48px rgba(20, 26, 40, 0.25);
}
.modal h2 {
  margin-top: 0;
}
.modal-actions {
  justify-content: flex-end;
  margin-top: 16px;
}
@media (min-width: 761px) {
  .nav-link:hover .nav-more,
  .nav-more:focus-visible {
    display: grid;
  }
  /* The count makes room for the dots. */
  .nav-link:hover .nav-count {
    margin-right: 0;
  }
}

/* ---- Webmail: the quick reply, printing, the dark look ------------------ */

/* The box under an open conversation. */
.quick-reply {
  margin-top: 20px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.quick-reply:focus-within {
  border-color: var(--accent);
}
.quick-text {
  display: block;
  width: 100%;
  min-height: 64px;
  margin: 0 0 8px;
  padding: 2px 0;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.quick-reply .notice {
  margin-bottom: 8px;
}
.quick-all {
  margin: 0 0 0 6px;
}
.cell-action {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
/* The choices of one setting, one under the other. */
.choices {
  display: grid;
  gap: 6px;
}

/* The page that's printed (webmail's print.rs) sits in a frame nobody sees. */
.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0;
  visibility: hidden;
}
/* The browser's own Print (Ctrl or Cmd + P) gives what's being read,
   without the rest of the window. */
@media print {
  .topbar,
  .rail,
  .sidebar,
  .list-pane,
  .read-toolbar,
  .thread-actions,
  .quick-reply,
  .fab,
  .print-frame {
    display: none !important;
  }
  html,
  body,
  .app,
  .app-mail,
  .app-body,
  .main,
  .split,
  .read-pane {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }
  .main {
    padding: 0 !important;
  }
}

/* One of the two is shown: the moon in the light look, the sun in the dark. */
.when-light,
.when-dark {
  display: inline-flex;
}
.when-dark,
:root[data-theme="dark"] .when-light {
  display: none;
}
:root[data-theme="dark"] .when-dark {
  display: inline-flex;
}

/* The dark look. The webmail's theme.js puts data-theme on the page before
   it's drawn. HTML mail keeps its white page: it was written for one. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #12151c;
  --surface: #1b1f29;
  --text: #e6e9ef;
  --muted: #9aa3b5;
  --border: #2d3442;
  --border-strong: #414a5c;
  --hover: #252b38;
  --hover-strong: #1f2531;
  --unread: #202636;

  --accent: #7ba4ff;
  --accent-from: #93b5ff;
  --accent-text: #0e1424;
  --accent-soft: #22304f;
  --ring: 0 0 0 3px rgba(123, 164, 255, 0.3);
  --accent-glow: rgba(123, 164, 255, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.6);
  --danger: #ff8a80;
  --danger-soft: #3b2022;
  --ok: #7dd88a;
  --ok-soft: #1a3323;
  --warn: #f2bb5e;
  --warn-soft: #3a2e14;
}
:root[data-theme="dark"] .avatar-1 {
  background: #22304f;
  color: #9dbbff;
}
:root[data-theme="dark"] .avatar-2 {
  background: #1a3323;
  color: #7dd88a;
}
:root[data-theme="dark"] .avatar-3 {
  background: #143540;
  color: #6fd0e6;
}
:root[data-theme="dark"] .avatar-4 {
  background: #3a2e14;
  color: #f2bb5e;
}
:root[data-theme="dark"] .avatar-5 {
  background: #3b2022;
  color: #ff9a91;
}
:root[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.55);
}
/* Paper is white: the browser's own Print gets the light colours. */
@media print {
  :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --text: #1c2230;
    --muted: #687082;
    --border: #e3e7ee;
    --border-strong: #cdd3de;
    --hover: #eff2f7;
    --hover-strong: #e4e8f0;
    --unread: #ffffff;
    --accent: #2459d6;
    --accent-from: #2f69e8;
    --accent-text: #ffffff;
    --accent-soft: #e8eefc;
    --danger: #c62828;
    --danger-soft: #fdecec;
    --ok: #2e7d32;
    --ok-soft: #e9f5ea;
    --warn: #8a5300;
    --warn-soft: #fff4e0;
  }
}
.choices .check {
  margin-bottom: 0;
}

/* ---- A fresher look, and motion ------------------------------------------
   Softer corners and light shadows, panes that float on the page's colour,
   and things that arrive instead of appearing. It all comes after the rules
   above and changes how they look, not what they are. Motion is switched
   off for people who asked their device for less of it (the last rule). */

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1,
h2,
h3 {
  letter-spacing: -0.015em;
}
a {
  text-underline-offset: 2px;
}
::selection {
  background: var(--accent-soft);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* The window in the middle keeps its own shift to the centre. */
@keyframes window-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}
@keyframes from-right {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Buttons and fields answer the pointer and the keyboard. */
.btn {
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
  transition:
    background-color var(--quick) ease,
    border-color var(--quick) ease,
    color var(--quick) ease,
    box-shadow var(--quick) ease,
    filter var(--quick) ease,
    transform var(--quick) var(--ease);
}
.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.btn-primary,
.btn-primary:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent-from), var(--accent));
}
.btn-primary {
  box-shadow:
    0 1px 2px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow:
    0 6px 16px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}
.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
}
.btn-quiet,
.btn-tool,
.btn-quiet:hover:not(:disabled),
.btn-tool:hover:not(:disabled) {
  border-color: transparent;
  box-shadow: none;
}
.btn-tool {
  border-radius: 10px;
}
.input {
  transition:
    border-color var(--quick) ease,
    box-shadow var(--quick) ease,
    background-color var(--quick) ease;
}
.input:hover {
  border-color: var(--border-strong);
}
.input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* Cards, notices and what's attached. */
.card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.notice {
  border-radius: 12px;
  animation: rise var(--smooth) var(--ease) both;
}
.attachment {
  border-radius: 12px;
  transition:
    background-color var(--quick) ease,
    border-color var(--quick) ease,
    box-shadow var(--quick) ease,
    transform var(--quick) var(--ease);
}
a.attachment:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.attachment-preview {
  border-radius: 14px;
  transition:
    box-shadow var(--smooth) ease,
    transform var(--smooth) var(--ease);
}
.attachment-preview:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.chip {
  border-radius: 8px;
}
.avatar {
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.05);
}

/* The sign-in pages: a card that arrives, under a little light. */
.auth {
  background:
    radial-gradient(900px 480px at 50% -8%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-box .card {
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  animation: rise 420ms var(--ease) both;
}

/* The navigation: a line that's pointed at warms up; unread mail counts
   in the accent. */
.nav-link {
  border-radius: 10px;
  transition:
    background-color var(--quick) ease,
    color var(--quick) ease,
    box-shadow var(--quick) ease;
}
.nav-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}
.nav-count-quiet {
  min-width: 0;
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
}

/* A page's parts arrive one after the other. */
.main:not(.main-split) > * {
  animation: rise var(--smooth) var(--ease) both;
}
.main:not(.main-split) > :nth-child(2) {
  animation-delay: 40ms;
}
.main:not(.main-split) > :nth-child(3) {
  animation-delay: 80ms;
}
.main:not(.main-split) > :nth-child(4) {
  animation-delay: 120ms;
}
.main:not(.main-split) > :nth-child(n + 5) {
  animation-delay: 160ms;
}

/* Conversations: a dot for unread mail, and rows that answer the pointer. */
.message {
  transition: background-color var(--quick) ease;
}
.message.unread .message-from::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}
.message-pick {
  transition: opacity var(--quick) ease;
}
.list-title {
  font-size: 20px;
}
/* The search box: filled, until it's typed in. */
.list-pane .toolbar .input-short {
  padding-left: 14px;
  border-color: transparent;
  border-radius: 999px;
  background: var(--bg);
}
.list-pane .toolbar .input-short:focus {
  border-color: var(--accent);
  background: var(--surface);
}
.toolbar .btn[title="Refresh"] .icon {
  transition: transform 420ms var(--ease);
}
.toolbar .btn[title="Refresh"]:hover .icon {
  transform: rotate(90deg);
}
.toolbar .btn[title="Refresh"]:active .icon {
  transform: rotate(270deg);
}
/* Rows glide in when a folder or a page of it is opened (the webmail marks
   the pane then), not each time the same list is read again. */
.list-pane.entering .message {
  animation: rise 340ms var(--ease) both;
}
.list-pane.entering .message:nth-child(2) {
  animation-delay: 25ms;
}
.list-pane.entering .message:nth-child(3) {
  animation-delay: 50ms;
}
.list-pane.entering .message:nth-child(4) {
  animation-delay: 75ms;
}
.list-pane.entering .message:nth-child(5) {
  animation-delay: 100ms;
}
.list-pane.entering .message:nth-child(6) {
  animation-delay: 125ms;
}
.list-pane.entering .message:nth-child(7) {
  animation-delay: 150ms;
}
.list-pane.entering .message:nth-child(8) {
  animation-delay: 175ms;
}
.list-pane.entering .message:nth-child(n + 9) {
  animation-delay: 200ms;
}

/* The open conversation: its messages are cards, and it arrives. */
.read-toolbar {
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
}
.read-title {
  margin-top: 18px;
  margin-bottom: 12px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.thread {
  display: grid;
  gap: 10px;
  animation: rise var(--smooth) var(--ease) both;
}
.thread-item,
.thread-item + .thread-item {
  min-width: 0;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  transition:
    border-color var(--quick) ease,
    box-shadow var(--quick) ease,
    background-color var(--quick) ease;
}
.thread-item:hover {
  border-color: var(--border-strong);
}
.thread-fold {
  padding: 10px 0;
}
.thread-fold:hover {
  background: none;
}
.thread-item:has(> .thread-fold):hover {
  background: var(--hover);
}
.thread-item > .mail-head {
  animation: fade var(--smooth) ease both;
}
.mail-frame {
  border-radius: 12px;
  animation: fade 320ms ease both;
}
.mail-text {
  animation: fade 320ms ease both;
}
.quick-reply {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--quick) ease,
    box-shadow var(--quick) ease;
}
.quick-reply:focus-within {
  box-shadow: var(--ring);
}
/* Nothing open: the envelope rests; motion is kept for what changes. */
.read-empty {
  animation: fade 400ms ease both;
}
.read-empty .icon {
  box-sizing: content-box;
  width: 40px;
  height: 40px;
  padding: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Menus and windows open from where they are. */
.menu {
  padding: 6px;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  transform-origin: top left;
  animation: pop 160ms var(--ease) both;
}
.menu-item {
  border-radius: 9px;
  transition: background-color var(--quick) ease;
}
.modal-backdrop {
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade 200ms ease both;
}
.modal {
  box-shadow: var(--shadow-lg);
  animation: window-in 240ms var(--ease) both;
}

/* Changing between the light and the dark look is a short fade. */
body,
.topbar,
.sidebar,
.rail,
.list-pane,
.read-pane,
.card {
  transition:
    background-color 220ms ease,
    border-color 220ms ease,
    color 220ms ease;
}

@media (min-width: 761px) {
  /* The three panes: the rail and the folders sit on the page's colour;
     the list and the conversation are two sheets on it. */
  .app-mail {
    grid-template-columns: 60px var(--sidebar) minmax(0, 1fr);
    background: var(--bg);
  }
  .rail {
    padding: 12px 0 14px;
    border-right: 0;
    background: none;
  }
  .rail-brand {
    display: block;
    width: 34px;
    height: 34px;
    margin-bottom: 10px;
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--accent-glow);
  }
  .rail-link {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    transition:
      background-color var(--quick) ease,
      color var(--quick) ease,
      box-shadow var(--quick) ease,
      transform var(--quick) var(--ease);
  }
  .rail-link:hover {
    background: var(--hover-strong);
  }
  .rail-link:active {
    transform: scale(0.92);
  }
  .rail-link.active {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .app-mail .sidebar {
    padding: 12px 8px 12px 2px;
    border-right: 0;
    background: none;
  }
  .side-account {
    border-bottom: 0;
  }
  .app-mail .nav-link:hover {
    background: var(--hover-strong);
  }
  .app-mail .nav-link.active {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .app-mail .main:not(.main-split) {
    padding: 24px 28px;
  }
  .app-mail .main-split {
    padding: 8px 8px 8px 0;
  }
  .split {
    gap: 8px;
  }
  .list-pane,
  .read-pane {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
  /* A conversation's row is a soft block of its own. */
  .list-pane .list {
    padding: 4px 6px 8px;
  }
  .list-pane .list > li + li {
    border-top: 0;
  }
  .list-pane .message {
    margin-top: 2px;
    border-radius: 12px;
  }
  .list-pane .message-link {
    padding: 11px 12px;
    border-radius: 12px;
  }
  .list-pane .message-link:hover {
    background: none;
  }
  .list-pane .message:hover {
    background: var(--hover);
  }
  .list-pane .message.unread {
    background: none;
  }
  .list-pane .message.unread:hover {
    background: var(--hover);
  }
  .list-pane .message.open,
  .list-pane .message.open.unread,
  .list-pane .message.picked {
    background: var(--accent-soft);
  }
  .list-pane .message-pick {
    left: 12px;
    top: 13px;
  }
  .list-pane .toolbar {
    border-bottom-color: transparent;
  }
  /* The round button to write: its shadow deepens when pointed at, and it
     gives a little when pressed. */
  .fab {
    background: linear-gradient(180deg, var(--accent-from), var(--accent));
    box-shadow: 0 8px 20px var(--accent-glow);
    transition:
      box-shadow var(--smooth) ease,
      transform var(--smooth) var(--ease);
  }
  .fab:hover {
    box-shadow: 0 10px 22px var(--accent-glow);
  }
  .fab:active {
    transform: scale(0.94);
  }
}
/* One pane at a time: the conversation comes in from the right, and the
   list fades back. */
@media (max-width: 1000px) {
  .split.has-open .read-pane {
    animation: from-right var(--smooth) var(--ease) both;
  }
  .split:not(.has-open) .list-pane {
    animation: fade var(--smooth) ease both;
  }
}
@media (max-width: 760px) {
  .rail-brand {
    display: none;
  }
  .nav .nav-write {
    background: linear-gradient(180deg, var(--accent-from), var(--accent));
    box-shadow: 0 8px 20px var(--accent-glow);
  }
}
/* ---- Webmail on a phone -------------------------------------------------
   A bar on top with the folders' button and the search; the folders in a
   drawer from the left; tabs at the foot of the screen; a round button to
   write; and an open conversation with the screen to itself, its actions
   above it and answering below. Wide windows have none of these parts. */

.topbar-button,
.drawer-close,
.drawer-foot,
.drawer-backdrop,
.rail-label,
.rail-phone,
.read-bottom {
  display: none;
}
/* The notice about a message's images: a picture, the words, the buttons. */
.note-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
}
.note-text {
  flex: 1 1 240px;
  min-width: 0;
}
.images-note .spacer {
  display: none;
}
@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 760px) {
  /* The top bar. */
  .app-mail > .topbar {
    gap: 10px;
    height: calc(60px + env(safe-area-inset-top));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
  }
  .topbar-button,
  .drawer-close {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--text);
    cursor: pointer;
    transition:
      background-color var(--quick) ease,
      transform var(--quick) var(--ease);
  }
  .topbar-button:active,
  .drawer-close:active {
    background: var(--hover);
    transform: scale(0.92);
  }
  .topbar-button .icon,
  .drawer-close .icon {
    width: 22px;
    height: 22px;
  }
  .app-mail > .topbar form {
    flex: 1;
    min-width: 0;
  }
  .app-mail > .topbar .input {
    width: 100%;
    max-width: none;
    min-height: 42px;
    padding: 0 16px;
    border-color: transparent;
    border-radius: 999px;
    background: var(--bg);
  }
  .app-mail > .topbar .input:focus {
    border-color: var(--accent);
    background: var(--surface);
  }
  .app-mail > .topbar .avatar {
    width: 38px;
    height: 38px;
  }

  /* The folders: a drawer from the left, over a dimmed page. */
  .app-mail .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 35;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: min(86vw, 340px);
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
    border-bottom: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateX(-104%);
    visibility: hidden;
    transition:
      transform 300ms var(--ease),
      visibility 0s linear 300ms;
  }
  .app-mail.drawer-open .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transition:
      transform 300ms var(--ease),
      visibility 0s;
  }
  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 34;
    background: rgba(10, 14, 24, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 260ms ease;
  }
  .app-mail.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .app-mail .side-account,
  .app-mail .side-account.has-chooser {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;
    margin-bottom: 6px;
    padding: 4px 0 12px 6px;
    border-bottom: 1px solid var(--border);
  }
  .app-mail .side-account .avatar,
  .app-mail .side-account.has-chooser .avatar {
    display: inline-flex;
    width: 42px;
    height: 42px;
    font-size: 15px;
  }
  .side-address {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
  }
  .side-account .nav-mailbox {
    flex: 1;
    min-width: 0;
    margin: 0;
  }
  .drawer-close {
    margin-left: auto;
  }
  .app-mail .nav {
    flex-direction: column;
    gap: 2px;
  }
  .app-mail .nav-heading {
    display: block;
    margin: 12px 12px 6px;
  }
  .app-mail .nav-link {
    min-height: 48px;
    gap: 14px;
    padding: 0 8px 0 14px;
    border-radius: 12px;
    font-size: 15.5px;
  }
  .app-mail .nav-link .icon {
    width: 20px;
    height: 20px;
  }
  .app-mail .nav-link.active {
    box-shadow: inset 3px 0 0 var(--accent);
  }
  /* A finger can't point without pressing: the dots are always there. */
  .app-mail .nav-link > .nav-more {
    display: grid;
    width: 38px;
    height: 38px;
    margin: 0 0 0 auto;
    border-radius: 10px;
  }
  .app-mail .nav-link > .nav-count + .nav-more {
    margin-left: 4px;
  }
  .app-mail .nav-link-quiet {
    font-size: 14px;
  }
  /* Writing has its round button; Rules and Settings are tabs. */
  .app-mail .nav .nav-write,
  .app-mail .nav-link-phone {
    display: none;
  }
  .drawer-foot {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }
  .drawer-foot .nav-link {
    width: 100%;
    border: 0;
    background: none;
    font: inherit;
    font-size: 15.5px;
    text-align: left;
    cursor: pointer;
  }
  .drawer-foot .when-light,
  .drawer-foot .when-dark {
    align-items: center;
  }

  /* The tabs at the foot of the screen. */
  .rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 0 max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom)
      max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
  }
  .rail-brand,
  .rail .spacer,
  .rail .rail-wide {
    display: none;
  }
  .rail-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    color: var(--muted);
    font-size: 11.5px;
    text-decoration: none;
    transition:
      color var(--quick) ease,
      transform var(--quick) var(--ease);
  }
  .rail-link .icon {
    width: 22px;
    height: 22px;
  }
  .rail-link:active {
    transform: scale(0.92);
  }
  .rail-label {
    display: block;
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
  }
  .rail-link.active {
    color: var(--text);
    font-weight: 600;
  }
  .rail-link.active .rail-label {
    border-bottom-color: currentColor;
  }
  .app-mail .main:not(.main-split) {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }
  .app-mail .main-split {
    padding-bottom: calc(150px + env(safe-area-inset-bottom));
  }
  /* The round button to write, above the tabs. */
  .fab {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 19;
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--accent-from), var(--accent));
    color: var(--accent-text);
    box-shadow: 0 8px 22px var(--accent-glow);
    transition: transform var(--quick) var(--ease);
  }
  .fab:active {
    transform: scale(0.92);
  }
  .fab .icon {
    width: 24px;
    height: 24px;
  }
  /* The offline line sits on the tabs, and the round button above it. */
  [data-network="offline"] body::after {
    bottom: calc(62px + env(safe-area-inset-bottom));
    padding-bottom: 8px;
  }
  [data-network="offline"] .fab {
    bottom: calc(118px + env(safe-area-inset-bottom));
  }

  /* The list: its name, with picking and refreshing at the end of the
     line; the search is in the top bar. */
  .list-pane {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .list-pane > * {
    grid-column: 1 / -1;
  }
  .list-pane > .list-head {
    grid-column: 1;
    align-items: center;
    padding: 12px 14px 8px;
  }
  .list-pane > .toolbar {
    position: static;
    border-bottom: 0;
  }
  .list-pane > .toolbar:not(.picking) {
    grid-column: 2;
    grid-row: 1;
    padding: 6px 10px 4px 0;
  }
  .list-pane .toolbar form {
    display: none;
  }
  .list-pane .message-link {
    padding: 13px 14px;
  }
  .list-pane .message-pick {
    opacity: 0;
    pointer-events: none;
  }
  .list-pane .message.picked .message-pick,
  .list-pane .toolbar.picking ~ .list .message-pick {
    opacity: 1;
    pointer-events: auto;
  }

  /* The search page's own box is the top bar's. */
  .app-mail .main:not(.main-split) .toolbar form[role="search"] {
    display: none;
  }

  /* An open conversation has the screen: no top bar, no tabs. */
  .app-mail.reading > .topbar,
  .app-mail.reading .rail {
    display: none;
  }
  .app-mail.reading .main-split {
    padding-bottom: 0;
  }
  .read {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: 0;
  }
  /* Its actions: a picture and a word each, in one line that scrolls. */
  .app-mail .read-toolbar {
    flex-wrap: nowrap;
    gap: 0;
    padding: calc(4px + env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) 4px
      max(4px, env(safe-area-inset-left));
    overflow-x: auto;
    scrollbar-width: none;
  }
  .app-mail .read-toolbar::-webkit-scrollbar {
    display: none;
  }
  .app-mail .read-toolbar .spacer,
  .app-mail .read-toolbar .tool-answer {
    display: none;
  }
  .app-mail .read-toolbar .btn-tool {
    flex: 1 0 auto;
    flex-direction: column;
    gap: 3px;
    min-width: 54px;
    min-height: 52px;
    padding: 5px 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
  }
  .app-mail .read-toolbar .btn-tool span {
    display: block;
  }
  .app-mail .read-toolbar .btn-tool .icon {
    width: 21px;
    height: 21px;
  }
  .app-mail .read-toolbar .read-back {
    flex: 0 0 auto;
    min-width: 44px;
  }
  .app-mail .read-toolbar .read-back span {
    display: none;
  }
  /* Moving is a list to choose from, dressed as the buttons beside it: the
     folder picture above its words. */
  .app-mail .read-toolbar .input-move {
    flex: 1 0 auto;
    -webkit-appearance: none;
    appearance: none;
    width: 58px;
    max-width: 64px;
    min-height: 52px;
    margin: 0;
    padding: 28px 2px 7px;
    border: 0;
    border-radius: 10px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a2030' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h6l2 2h10v11H3z M9 14h6 M13 11l3 3-3 3'/%3E%3C/svg%3E") center 7px / 21px 21px no-repeat;
    box-shadow: none;
    color: var(--text);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    text-align-last: center;
  }
  :root[data-theme="dark"] .app-mail .read-toolbar .input-move {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e6e9ef' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h6l2 2h10v11H3z M9 14h6 M13 11l3 3-3 3'/%3E%3C/svg%3E");
  }
  .app-mail .read-toolbar .btn-danger {
    flex: 0 0 auto;
    margin: 0 4px;
    white-space: nowrap;
  }
  .read-title {
    margin-top: 16px;
    font-size: 20px;
  }
  /* Its messages run from edge to edge, a line between them. */
  .thread {
    gap: 0;
  }
  .thread-item,
  .thread-item + .thread-item {
    padding: 0;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: none;
  }
  .thread-item:first-child {
    border-top: 0;
  }
  .thread-item:has(> .thread-fold):hover {
    background: none;
  }
  .thread-fold {
    padding: 12px 0;
  }
  .quick-reply {
    margin-bottom: 16px;
  }
  /* Answering, and the conversations before and after, below it. */
  .read > .read-bottom {
    position: sticky;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    flex-shrink: 0;
    height: calc(62px + env(safe-area-inset-bottom));
    margin: auto 0 0;
    padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom)
      max(4px, env(safe-area-inset-left));
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
  }
  .read-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    color: var(--text);
    font-size: 11.5px;
    text-decoration: none;
    transition: transform var(--quick) var(--ease);
  }
  .read-step .icon {
    width: 22px;
    height: 22px;
  }
  .read-step:active {
    transform: scale(0.92);
  }
  .read-step.disabled {
    color: var(--muted);
    opacity: 0.4;
    pointer-events: none;
  }

  /* A folder's menu comes up from the foot of the screen. */
  .menu {
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: calc(8px + env(safe-area-inset-bottom));
    max-width: none;
    padding: 8px;
    border-radius: 18px;
    animation: sheet-up 260ms var(--ease) both;
  }
  .menu-backdrop {
    background: rgba(10, 14, 24, 0.45);
    animation: fade 200ms ease both;
  }
  .menu-item {
    min-height: 48px;
    font-size: 15.5px;
  }
}
/* ---- Webmail: stars and tags ----------------------------------------------
   A star is the same warm yellow wherever it's drawn. A tag has one of eight
   colours: --tag is its dot, --tag-soft and --tag-text its label. */

:root {
  --star: #e6a100;
}
:root[data-theme="dark"] {
  --star: #f2cc5e;
}
.tag-red {
  --tag: #d93025;
  --tag-soft: #fdecec;
  --tag-text: #b3261e;
}
.tag-orange {
  --tag: #e8710a;
  --tag-soft: #fff0e1;
  --tag-text: #9a4a00;
}
.tag-yellow {
  --tag: #e0a800;
  --tag-soft: #fff7d6;
  --tag-text: #7a5b00;
}
.tag-green {
  --tag: #2e7d32;
  --tag-soft: #e9f5ea;
  --tag-text: #256428;
}
.tag-teal {
  --tag: #0e8a9a;
  --tag-soft: #e6f4f8;
  --tag-text: #0e6373;
}
.tag-blue {
  --tag: #2459d6;
  --tag-soft: #e8eefc;
  --tag-text: #1d48ad;
}
.tag-purple {
  --tag: #7b3fd1;
  --tag-soft: #f1e9fc;
  --tag-text: #5e2ca5;
}
.tag-grey {
  --tag: #6b7385;
  --tag-soft: #eef0f4;
  --tag-text: #4a5263;
}
:root[data-theme="dark"] .tag-red {
  --tag: #ff8a80;
  --tag-soft: #3b2022;
  --tag-text: #ff9a91;
}
:root[data-theme="dark"] .tag-orange {
  --tag: #ffa45c;
  --tag-soft: #3a2714;
  --tag-text: #ffb67a;
}
:root[data-theme="dark"] .tag-yellow {
  --tag: #f2cc5e;
  --tag-soft: #3a3114;
  --tag-text: #f2cc5e;
}
:root[data-theme="dark"] .tag-green {
  --tag: #7dd88a;
  --tag-soft: #1a3323;
  --tag-text: #7dd88a;
}
:root[data-theme="dark"] .tag-teal {
  --tag: #6fd0e6;
  --tag-soft: #143540;
  --tag-text: #6fd0e6;
}
:root[data-theme="dark"] .tag-blue {
  --tag: #7ba4ff;
  --tag-soft: #22304f;
  --tag-text: #9dbbff;
}
:root[data-theme="dark"] .tag-purple {
  --tag: #b99cff;
  --tag-soft: #2c2447;
  --tag-text: #c7b0ff;
}
:root[data-theme="dark"] .tag-grey {
  --tag: #9aa3b5;
  --tag-soft: #2a303c;
  --tag-text: #c3c9d6;
}
.tag-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  /* With its margins, as wide as an icon: names line up under each other. */
  margin: 0 4px;
  border-radius: 50%;
  background: var(--tag, var(--muted));
}
.chip.tag-chip {
  border-color: transparent;
  background: var(--tag-soft, var(--hover));
  color: var(--tag-text, var(--text));
  font-weight: 600;
}
/* The side bar: a tag's name gives way to its count. */
.nav-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The star: on a conversation's row, on an open message, in the toolbars. */
.message-star,
.mail-star {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition:
    color var(--quick) ease,
    background-color var(--quick) ease,
    opacity var(--quick) ease,
    transform var(--quick) var(--ease);
}
.message-star:hover,
.mail-star:hover {
  background: var(--hover);
  color: var(--star);
}
.message-star:active,
.mail-star:active {
  transform: scale(0.82);
}
.message-star.on,
.mail-star.on,
.btn.btn-star.on,
.message-starred {
  color: var(--star);
}
.message-star.on .icon,
.mail-star.on .icon,
.btn-star.on .icon,
.message-starred .icon {
  fill: currentColor;
}
/* On a row it sits under the time, and shows when the row is pointed at
   or has one. */
.message-star {
  position: absolute;
  right: 8px;
  top: 31px;
  z-index: 1;
  opacity: 0;
}
.message:hover .message-star,
.message-star.on,
.message-star:focus-visible {
  opacity: 1;
}
.list-pane .message-subject {
  padding-right: 28px;
}
/* A finger can't point: there it's always shown. */
@media (hover: none) {
  .message-star {
    opacity: 1;
  }
}
.mail-star {
  margin: -6px -6px 0 -4px;
}
/* A starred message among search results. */
.message-starred {
  display: inline-flex;
  margin-left: 6px;
  vertical-align: -2px;
}
.message-starred .icon {
  width: 14px;
  height: 14px;
}

/* An open conversation's tags, under its subject; a cross takes one off. */
.read-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 14px;
  animation: fade var(--smooth) ease both;
}
.read-tags .chip {
  padding: 3px 6px 3px 10px;
  font-size: 13px;
}
.chip-off {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
}
.chip-off:hover {
  opacity: 1;
  background: var(--surface);
}
.chip .chip-off .icon {
  width: 12px;
  height: 12px;
  color: inherit;
}

/* The menu that puts tags on and takes them off. */
.menu-tags {
  max-height: min(70vh, 420px);
  overflow-y: auto;
}
.menu-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-tick {
  color: var(--accent);
  font-weight: 600;
}
.menu-note {
  max-width: 250px;
  padding: 2px 10px 8px;
}

/* The tags page: a colour is chosen from round buttons. */
.tag-colours {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.tag-colour {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
}
.tag-colour input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.tag-colour .tag-dot {
  width: 18px;
  height: 18px;
  margin: 0;
  transition:
    transform var(--quick) var(--ease),
    box-shadow var(--quick) ease;
}
.tag-colour:hover .tag-dot {
  transform: scale(1.12);
}
.tag-colour input:checked + .tag-dot {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--tag);
}
.tag-colour input:focus-visible + .tag-dot {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--accent);
}
.tag-link {
  text-decoration: none;
}
.tag-link .chip {
  padding: 3px 10px;
  font-size: 13.5px;
}
@media (max-width: 760px) {
  .message-star {
    opacity: 1;
    right: 6px;
    top: 34px;
    width: 36px;
    height: 36px;
  }
  /* A message's date goes under the sender, its star at that line's end. */
  .mail-head > .mail-when {
    margin-left: 46px;
  }
  .mail-head > .mail-star {
    margin: -7px -6px -4px auto;
  }
  .list-pane .message-subject {
    padding-right: 34px;
  }
}
@media print {
  .message-star,
  .mail-star,
  .chip-off {
    display: none !important;
  }
}
/* ---- Webmail: folders inside folders, muted folders -----------------------
   A folder inside another is set in by how deep it sits (--depth). */

.nav-link.nav-inner {
  padding-left: calc(10px + var(--depth, 0) * 16px);
}
/* The arrow after a folder's name that folds its folders away. */
.nav-fold {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: -2px 0 -2px -4px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.nav-fold:hover {
  background: var(--border);
  color: var(--text);
}
.nav-link .nav-fold .icon {
  width: 14px;
  height: 14px;
  color: inherit;
  transition: transform var(--quick) var(--ease);
}
.nav-link .nav-fold.folded .icon {
  transform: rotate(-90deg);
}
/* A folder whose new mail isn't announced. */
.nav-muted {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--muted);
}
.nav-link .nav-muted .icon {
  width: 14px;
  height: 14px;
  color: inherit;
}
/* The folders page: the same setting in, and where a folder goes. */
.table td.folder-cell {
  padding-left: calc(16px + var(--depth, 0) * 22px);
}
.input-place {
  width: auto;
  max-width: 240px;
}
@media (max-width: 760px) {
  .app-mail .nav-link.nav-inner {
    padding-left: calc(14px + var(--depth, 0) * 18px);
  }
  .app-mail .nav-fold {
    width: 34px;
    height: 34px;
    margin: 0 0 0 -2px;
    border-radius: 10px;
  }
  .app-mail .nav-link .nav-fold .icon {
    width: 18px;
    height: 18px;
  }
  .input-place {
    max-width: 100%;
  }
}
/* ---- Webmail: sending later ------------------------------------------------ */

/* The times offered with one click; the one chosen is marked. */
.later-offers {
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.btn.btn-chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
/* A message that wasn't sent at its time: the count by "Scheduled". */
.nav-count.nav-count-danger {
  background: var(--danger);
  color: #ffffff;
}
/* The scheduled messages: what, when, and what can be done with each. */
.scheduled {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.scheduled:last-child {
  border-bottom: 0;
}
.scheduled .avatar .icon {
  width: 18px;
  height: 18px;
}
.scheduled-what {
  flex: 1;
  min-width: 0;
}
.scheduled-when {
  margin-top: 4px;
}
.scheduled-failed .scheduled-when {
  color: var(--danger);
}
.scheduled-actions {
  flex-shrink: 0;
}
@media (max-width: 760px) {
  .scheduled {
    flex-wrap: wrap;
  }
  .scheduled-actions {
    width: 100%;
    padding-left: 46px;
  }
}
/* ---- Dashboard: routing and the delivery test ------------------------------ */

/* When the relay is used: a word, and what it means under it. */
.route-choice {
  align-items: flex-start;
  margin-bottom: 12px;
}
.route-choice input {
  margin-top: 4px;
}
.route-choice > span {
  display: grid;
  gap: 2px;
}
/* The relay's fields side by side while there's room. */
.route-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}
/* The delivery test: the address beside its button. */
.test-form {
  flex-wrap: nowrap;
  margin-bottom: 10px;
}
.test-form .input {
  flex: 1;
  min-width: 0;
}
/* A list of plain sentences. */
.plain-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}
/* ---- Mailbox sizes: how full a mailbox is ------------------------------------ */

.meter {
  height: 8px;
  min-width: 120px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 4px;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}
.meter-nearly > span {
  background: var(--warn, #b26a00);
}
.meter-full > span {
  background: var(--danger);
}
/* A label beside its field, in a row of a form. */
.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.field-inline > span {
  margin: 0;
}
.limit-form {
  margin-top: 14px;
}

/* ---- Webmail: the out-of-office reply --------------------------------------- */

/* How the reply stands, above its switch. */
.away-state {
  margin: 0 0 12px;
}
/* Its first and last day side by side while there's room. */
.away-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 16px;
}
.away-days + .hint {
  margin-bottom: 14px;
}

/* ---- Dashboard: sending for apps -------------------------------------------- */

/* An app password that stopped working. */
.danger-text {
  color: var(--danger);
}
/* A form that holds a card, between other cards: the same gap as theirs. */
form + .card,
.card + form {
  margin-top: var(--gap);
}
/* Notes under a form's buttons, or under the last card of a page. */
.row + .plain-list,
.card ~ .plain-list {
  margin-top: 14px;
}
/* What an app password is for: wide enough to read on a narrow screen,
   where the table scrolls sideways. */
.app-for {
  min-width: 170px;
}
@media print {
  .list-pane,
  .read-pane,
  .thread-item {
    border: 0 !important;
    box-shadow: none !important;
  }
}
/* Less motion for those who asked their device for it. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* A form under a card's table keeps its distance. */
.card > .table + form,
.card > .table + .row {
  margin-top: 12px;
}


/* ---- Webmail: moving mail by hand ---------------------------------------- */
/* A folder's dots sit at the far end of its line, away from its name, with
   or without a count before them. */
.nav-link > .nav-more {
  margin-left: auto;
}
.nav-link > .nav-count + .nav-more {
  margin-left: 0;
}
/* The folder that conversations dragged from the list would go to. What's
   in it doesn't take the pointer meanwhile, so the mark doesn't flicker. */
.nav-link.drop-target {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--accent);
}
.nav-link.drop-target > * {
  pointer-events: none;
}
/* The rows being dragged. */
.message.dragged {
  opacity: 0.45;
}
/* The folders to move to: a long list scrolls. */
.menu-move {
  max-height: min(70vh, 420px);
  overflow-y: auto;
}


/* ---- Dashboard: the home page and its graphs ----------------------------- */
/* A graph's colours say what happened to mail, the same in every graph:
   blue went where it should, aqua was set aside, orange didn't get through.
   The three can be told apart with any colour vision, on both surfaces
   (checked with a colour-blindness simulation), and every graph has its
   numbers as a table too, so nothing is said by colour alone. */
:root {
  --series-through: #2a78d6;
  --series-aside: #1baf7a;
  --series-stopped: #eb6834;
}
:root[data-theme="dark"] {
  --series-through: #3987e5;
  --series-aside: #199e70;
  --series-stopped: #d95926;
}
.series-through {
  background: var(--series-through);
}
.series-aside {
  background: var(--series-aside);
}
.series-stopped {
  background: var(--series-stopped);
}

/* While fresh numbers load, the page keeps what it shows. */
.overview {
  transition: opacity var(--quick) ease;
}
.overview.is-loading {
  opacity: 0.6;
}
.section-title {
  margin: 24px 0 12px;
  font-size: 16px;
}
.section-row {
  margin: 24px 0 12px;
  gap: 12px;
}
.section-row > .section-title {
  margin: 0;
}

/* The issues that are open, under the opening line. */
.issue-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.issue-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

/* A number with what it is. */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: var(--gap);
}
.tiles-six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
/* A line that belongs to the tiles above it. */
.tiles-note {
  margin-top: calc(-1 * var(--gap) + 8px);
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none;
}
.tile-link {
  transition:
    border-color var(--quick) ease,
    box-shadow var(--quick) ease;
}
.tile-link:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.tile-link:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.tile-label,
.tile-note {
  font-size: 13px;
  color: var(--muted);
}
.tile-note {
  font-size: 12px;
  min-height: 18px;
}
.tile-value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
}

/* The choice of period: one row of buttons that belong together. */
.seg-control {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.seg-item {
  border: 0;
  padding: 5px 14px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.seg-item + .seg-item {
  border-left: 1px solid var(--border);
}
.seg-item:hover {
  background: var(--hover);
}
.seg-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.seg-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* The graphs, two beside each other where there's room. */
.charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.charts > .card + .card {
  margin-top: 0;
}
.chart {
  min-width: 0;
}
.chart-about {
  margin-bottom: 12px;
}
.chart-empty {
  padding: 28px 16px;
}
.chart-off {
  display: none !important;
}
.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 12px;
  padding: 0;
  font-size: 13px;
}
.legend > li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.swatch {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* A graph of columns: the numbers of the axis, the plot, and the hours or
   days under it. */
.chart-plot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  padding-top: 8px;
}
.plot-y {
  position: relative;
  height: 160px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* Makes room for the longest number; the numbers themselves sit on their
   lines. */
.plot-y-size {
  visibility: hidden;
}
.tick {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
}
.tick-top {
  top: 0;
}
.tick-half {
  top: 50%;
}
.tick-zero {
  top: 100%;
}
.plot-area {
  position: relative;
  height: 160px;
}
.plot-grid > span {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.plot-grid > span:nth-child(2) {
  top: 50%;
}
/* The line the columns stand on. */
.plot-grid > span:nth-child(3) {
  top: 100%;
  background: var(--border-strong);
}
.plot-cols {
  position: absolute;
  inset: 0;
  display: flex;
}
/* One hour or day: the whole height takes the pointer, not just the bar. */
.col {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1px;
  outline: none;
}
.col:hover,
.col:focus {
  background: var(--hover);
}
/* The bar: its parts stacked from the line up, a gap of the surface between
   them, the top one rounded. */
.col-stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  width: 100%;
  max-width: 24px;
  min-height: 2px;
}
.col-stack:empty {
  min-height: 0;
}
.seg {
  display: block;
  flex: 1 1 0;
  min-height: 2px;
}
.col-stack > .seg:last-child {
  border-radius: 4px 4px 0 0;
}
.col:hover .seg,
.col:focus .seg {
  filter: brightness(1.12);
}
/* What a column stands for, shown while it's pointed at or tapped. */
.tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
}
.tip-left {
  left: 0;
  transform: none;
}
.tip-right {
  left: auto;
  right: 0;
  transform: none;
}
.col:hover > .tip,
.col:focus > .tip {
  display: block;
}
.tip-title {
  margin-bottom: 2px;
  font-weight: 600;
}
.tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.tip-row > strong {
  min-width: 2ch;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tip-total {
  margin-top: 2px;
  padding-top: 2px;
  border-top: 1px solid var(--border);
}
.key {
  flex: none;
  width: 12px;
  height: 3px;
  border-radius: 2px;
}
.plot-x {
  grid-column: 2;
  display: flex;
  height: 18px;
  margin-top: 6px;
  font-size: 12px;
  line-height: 18px;
  color: var(--muted);
}
.plot-x > span {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
}
.plot-x > span > span {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}
.chart-table {
  max-height: 320px;
  overflow-y: auto;
}

/* Names with a bar each, the number at the end of the line. */
.ranked {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: fit-content(52%) minmax(48px, 1fr) auto;
  gap: 10px 12px;
  align-items: center;
  font-size: 14px;
}
.ranked > li {
  display: contents;
}
.ranked-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.ranked-bar {
  display: block;
  height: 12px;
}
.ranked-bar > span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 0 4px 4px 0;
}
.ranked-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* What is stored: a name, a bar against its limit, and the figures. */
.meter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: fit-content(40%) minmax(0, 1fr);
  gap: 12px 16px;
  align-items: start;
}
.meter-list > li {
  display: contents;
}
.meter-name {
  min-width: 0;
  font-weight: 600;
}
.meter-cell {
  display: block;
  min-width: 0;
}
.meter-cell > .meter {
  display: block;
  margin-top: 7px;
}
.meter-cell > .small {
  display: block;
}

@media (max-width: 1280px) {
  .tiles-six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .charts {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 760px) {
  .tiles,
  .tiles-six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  /* The bar drops under its name. */
  .ranked {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
  }
  .ranked-name {
    grid-column: 1 / -1;
  }
  .ranked > li + li > .ranked-name {
    margin-top: 8px;
  }
  .meter-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .meter-list > li + li > .meter-name {
    margin-top: 12px;
  }
  .tile-value {
    font-size: 22px;
  }
  .plot-x {
    font-size: 11px;
  }
}

/* ---- Webmail: a message's details ---------------------------------------- */

/* "Details" after the recipients of an open message: a quiet text button. */
.details-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 2px;
  padding: 1px 7px 1px 3px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  vertical-align: baseline;
}
.details-toggle:hover {
  background: var(--hover);
  color: var(--text);
}
.details-toggle:focus-visible {
  outline: 0;
  box-shadow: var(--ring);
}
.details-toggle .icon {
  width: 14px;
  height: 14px;
  transition: transform var(--quick) ease;
}
.details-toggle.open .icon {
  transform: rotate(180deg);
}
/* The panel: parts side by side where there's room, one column on a phone. */
.mail-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 18px 32px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  animation: fade 200ms ease both;
}
.details-part {
  min-width: 0;
}
.details-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
}
.details-about {
  margin: -4px 0 10px;
}
.details-rows {
  display: grid;
  grid-template-columns: minmax(88px, max-content) minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
}
.details-rows dt {
  color: var(--muted);
}
.details-rows dd {
  margin: 0;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* One check: an icon, its name, the result in words, what it was about.
   The icon and the words say the result; the colour only repeats it. */
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px 4px 8px;
  border-radius: 8px;
  background: var(--hover);
}
.check .icon {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
}
.check strong {
  font-weight: 600;
  white-space: nowrap;
}
.check-word {
  font-weight: 600;
  white-space: nowrap;
}
.check-word::before,
.check-detail::before {
  content: "\00b7";
  margin-right: 6px;
  color: var(--muted);
  font-weight: 400;
}
.check-good {
  background: var(--ok-soft);
}
.check-good .icon,
.check-good .check-word {
  color: var(--ok);
}
.check-bad {
  background: var(--danger-soft);
}
.check-bad .icon,
.check-bad .check-word {
  color: var(--danger);
}
.check-unsure {
  background: var(--warn-soft);
}
.check-unsure .icon,
.check-unsure .check-word {
  color: var(--warn);
}
.check-quiet .icon,
.check-quiet .check-word {
  color: var(--muted);
}
/* Why nothing was checked: a sentence, not chips. */
.check-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
}
.check-line .icon {
  margin-top: 2px;
}

/* ---- Dashboard: connection settings --------------------------------------- */

/* One card for each kind of connection. On a narrow screen they follow
   each other, with sending second: it is the one with values to enter. */
.connections {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.connections-side {
  display: contents;
}
.connections .card + .card {
  margin-top: 0;
}
.connection {
  display: flex;
  flex-direction: column;
  order: 3;
}
.connection-first {
  order: 1;
}
.connection-second {
  order: 2;
}
/* With room for two: mail coming in on the left, mail going out on the
   right. */
@media (min-width: 1120px) {
  .connections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .connections-side {
    display: grid;
    gap: var(--gap);
    min-width: 0;
  }
}
.connection > p {
  margin: 0 0 12px;
}
.connection-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.connection-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}
.connection-icon svg {
  width: 22px;
  height: 22px;
}
/* A kind of connection this server doesn't have, or has switched off. */
.connection-none .connection-icon {
  background: var(--hover);
  color: var(--muted);
}
.connection-title {
  flex: 1;
  min-width: 0;
}
.connection-title h2 {
  margin: 0;
}
.connection-purpose {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
/* What to use where a kind of connection is missing. */
.connection-instead {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--hover);
}
/* One setting a line: its name, then its value with a button that copies
   it, and a note under both. */
.settings {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.setting {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 8px 8px 14px;
}
.setting + .setting {
  border-top: 1px solid var(--border);
}
.setting dt {
  font-size: 13px;
  color: var(--muted);
}
.setting dd {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  margin: 0;
  min-width: 0;
}
.setting-value {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
/* A value that is typed into an app as it stands. */
.setting-exact {
  font-family: var(--mono);
  font-size: 14px;
}
.setting-note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
}
.btn-copy {
  justify-content: center;
  min-width: 84px;
}
@media (max-width: 480px) {
  .setting {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
}
