/* Aliasdock: plain, responsive layout without a framework.
 *
 * Layout from 55rem width: the header is fixed, below it sidebar and
 * content fill the remaining height. Both scroll individually so the
 * menu always reaches the bottom edge and stays put while paging through
 * a long mail list.
 *
 * Below that (phone, narrow window) the normal text flow applies: the
 * menu sits as a compact, wrapping bar above the content, the page
 * scrolls as a whole.
 */

:root {
  --bg: #ffffff;
  --bg-2: #f5f6f8;
  --border: #d8dbe0;
  --text: #1c1f24;
  --text-muted: #5c636e;
  --accent: #1f5fa9;
  --accent-text: #ffffff;
  --warning: #a4262c;
  --success: #1d6f42;
  --radius: 6px;
  --sidebar-width: 15rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --bg-2: #1e2126;
    --border: #333941;
    --text: #e6e8ec;
    --text-muted: #a0a7b2;
    --accent: #6ea8fe;
    --accent-text: #10131a;
    --warning: #ff8f8f;
    --success: #7ddba3;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--accent);
  color: var(--accent-text); padding: .5rem 1rem; z-index: 10;
}
.skip-link:focus { left: 0; }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .6rem 1rem;
  border-bottom: 1px solid var(--border); background: var(--bg-2);
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.header-nav { display: flex; align-items: center; gap: .75rem; }
.user { color: var(--text-muted); font-size: .9rem; overflow-wrap: anywhere; }

/* Body */
.page-body { display: flex; align-items: stretch; gap: 0; }
.page-body-narrow { justify-content: center; }
.sidebar {
  flex: 0 0 var(--sidebar-width);
  display: flex; flex-direction: column;
  padding: 1rem; border-right: 1px solid var(--border); background: var(--bg-2);
}
.content { flex: 1 1 auto; padding: 1rem 1.25rem 3rem; min-width: 0; }
.page-body:not(.page-body-narrow) .content { max-width: 72rem; }
.page-body-narrow .content { max-width: 30rem; width: 100%; }

.group {
  margin: 1rem 0 .25rem; font-size: .75rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-muted);
}
.group:first-child { margin-top: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list a {
  display: block; padding: .3rem .5rem; border-radius: var(--radius);
  text-decoration: none; color: var(--text);
}
.list a:hover { background: var(--bg); }
.list a.active { background: var(--bg); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.heading-sub { font-weight: 400; color: var(--text-muted); }
.counter {
  display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font-size: .75rem; text-align: center;
}
.dot {
  display: inline-block; width: .7em; height: .7em; border-radius: 50%;
  margin-right: .35em; vertical-align: baseline;
}
/* Pushes the version to the bottom edge of the sidebar. */
.version { margin: auto 0 0; padding-top: 1rem; color: var(--text-muted); font-size: .8rem; }

h1 { font-size: 1.5rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .3rem; }
.lead { color: var(--text-muted); margin-top: 0; }
.small { color: var(--text-muted); font-size: .85rem; }
.wrap { overflow-wrap: anywhere; }
.empty { color: var(--text-muted); padding: 2rem 0; }
.right { text-align: right; }
.back { margin: 0 0 .5rem; }

/* Cards and forms */
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-2); padding: 1rem; margin: 0 0 1.25rem;
}
.form p { margin: 0 0 .8rem; }
.form label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input[type=number], .form input[type=search], .form select, .form textarea {
  width: 100%; max-width: 32rem; padding: .45rem .55rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit;
}

.row select, .mail-actions select {
  padding: .4rem .5rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit; max-width: 100%;
}

/* Checkboxes: drawn in CSS instead of the browser default so they follow
   the theme. The tick is a rotated border, no image: the CSP allows none
   from data: URIs. */
input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: 0 0 auto;
  width: 1.15rem; height: 1.15rem; margin: 0 .4rem 0 0;
  vertical-align: -.2rem; cursor: pointer;
  border: 1.5px solid var(--text-muted); border-radius: 4px;
  background: var(--bg);
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
input[type=checkbox]:hover { border-color: var(--accent); }
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]::after {
  content: ""; position: absolute; left: 50%; top: 45%;
  width: .3rem; height: .6rem;
  border: solid var(--accent-text); border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0);
  transition: transform .12s;
}
input[type=checkbox]:checked::after { transform: translate(-50%, -50%) rotate(45deg) scale(1); }
input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }
label:has(> input[type=checkbox]) { cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
  input[type=checkbox], input[type=checkbox]::after { transition: none; }
}
.help { display: block; color: var(--text-muted); font-size: .85rem; margin-top: .2rem; max-width: 40rem; }
.row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0 0 .5rem; }
.inline { display: inline; }

/* Buttons */
.btn {
  display: inline-block; padding: .4rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-plain { background: transparent; }
.btn-small { padding: .2rem .45rem; font-size: .85rem; }
.btn-danger { color: var(--warning); border-color: var(--warning); }

/* Notices */
.notice {
  margin: .75rem 1rem; padding: .6rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-2);
}
.content .notice { margin: .75rem 0; }
.notice-success { border-color: var(--success); }
.notice-error { border-color: var(--warning); }
.error-message {
  padding: .6rem .9rem; border: 1px solid var(--warning); border-radius: var(--radius);
  color: var(--warning); background: var(--bg-2);
}

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 .8rem; border-bottom: 1px solid var(--border); }
.tab {
  padding: .4rem .7rem; text-decoration: none; color: var(--text);
  border: 1px solid transparent; border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
}
.tab.active { border-color: var(--border); background: var(--bg-2); font-weight: 600; }

/* Getting started */
.badge {
  display: inline-block; margin-left: .4rem; padding: .05rem .5rem; border-radius: 999px;
  border: 1px solid var(--border); font-size: .75rem; font-weight: 500;
  color: var(--text-muted); vertical-align: middle;
}
.badge-done { border-color: var(--accent); color: var(--accent); }
.welcome-section { margin: 0 0 1.75rem; }
.welcome-section h3 { margin: 0 0 .35rem; font-size: 1rem; }
.welcome-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .9rem; }
.welcome-concept { margin: 0; }
.welcome-concept p { margin: 0; color: var(--text-muted); }
.welcome-icon {
  display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; margin-bottom: .5rem;
  border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700;
}
.welcome-steps { list-style: none; margin: .75rem 0 0; padding: 0; }
.welcome-step { position: relative; display: flex; gap: .9rem; padding: 0 0 1.25rem; }
/* The line connecting the step markers. */
.welcome-step:not(:last-child)::before {
  content: ""; position: absolute; left: 1rem; top: 2.2rem; bottom: .2rem;
  width: 2px; margin-left: -1px; background: var(--border);
}
.welcome-step-mark {
  flex: 0 0 auto; display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 50%; border: 2px solid var(--border); background: var(--bg);
  font-weight: 700; color: var(--text-muted);
}
.welcome-step.done .welcome-step-mark { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.welcome-step-body { flex: 1 1 auto; min-width: 0; padding-top: .2rem; }
.welcome-step-body p { margin: 0 0 .6rem; color: var(--text-muted); max-width: 44rem; }
.welcome-finish p { margin: 0 0 .75rem; }
.welcome-finish-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.welcome-hint { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin: 0 0 1rem; }
.welcome-hint-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; }

/* Filters */
.filter { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin: 0 0 .8rem; }
.filter-field { margin: 0; }
.filter-field label { display: block; font-size: .8rem; color: var(--text-muted); }
.filter-field input, .filter-field select {
  padding: .35rem .5rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit; max-width: 100%;
}
.filter-toggle label { display: block; font-size: .9rem; color: var(--text); padding-top: 1rem; }

/* Tables. The frame catches wide tables so the page itself never has to
   scroll horizontally. */
/* position: relative is necessary, not decoration: without a positioned
   ancestor the absolutely positioned .sr-only elements in the table
   headers refer to the viewport. They would then sit at their static
   position inside the horizontally scrolled table and make the page
   itself wider. */
.table-wrap { overflow-x: auto; margin: .5rem 0 1rem; position: relative; }
.table, .mail-list { width: 100%; border-collapse: collapse; }
.table th, .table td, .mail-list th, .mail-list td {
  text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th, .mail-list th { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.mail-list tr.unread { font-weight: 600; }
.mail-list a { text-decoration: none; }
.mail-list a:hover { text-decoration: underline; }
.col-select { width: 2rem; }
.col-select input[type=checkbox] { margin: 0; }
.col-date { width: 7rem; white-space: nowrap; color: var(--text-muted); }
.col-sender { width: 16rem; }
.col-category { width: 10rem; }
.col-sender .small { display: block; font-weight: 400; }
.actions { white-space: nowrap; }
.actions > * { margin-right: .25rem; }
.bulk-action {
  display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
  padding: .5rem 0; border-bottom: 1px solid var(--border);
}
.bulk-action .all { margin-right: .5rem; }
.paging { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0; }

/* Quick actions in the mail list */
.col-quick { width: 9rem; white-space: nowrap; text-align: right; }
.btn-quick {
  padding: .1rem .4rem; font-size: .95rem; line-height: 1.3;
  min-width: 1.9rem; text-align: center;
}
.mail-list tr:not(:hover) .btn-quick { border-color: transparent; }
.mail-list tr:hover .btn-quick { border-color: var(--border); }
.btn-quick:focus-visible { border-color: var(--accent); }

/* Mail view */
.mail-headers { display: grid; grid-template-columns: 9rem 1fr; gap: .2rem .8rem; margin: 0 0 1rem; }
.mail-headers dt { color: var(--text-muted); font-size: .9rem; }
.mail-headers dd { margin: 0; overflow-wrap: anywhere; }
.mail-actions { margin: 0 0 1rem; }
.mail-meta { margin: -.3rem 0 .9rem; overflow-wrap: anywhere; }
.mail-meta .mail-date { margin-left: .5rem; }
.mail-details { margin: 0 0 .5rem; }
.mail-frame {
  width: 100%; height: 65vh; min-height: 18rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.mail-text {
  white-space: pre-wrap; overflow-wrap: anywhere; padding: 1rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-2);
}
.dns {
  padding: .75rem; overflow-x: auto; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.address {
  padding: .1rem .3rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-wrap: anywhere;
}
.warning {
  display: inline-block; margin-left: .35em; padding: 0 .35em;
  border: 1px solid var(--warning); border-radius: var(--radius);
  color: var(--warning); font-size: .8rem;
}

/* Category colors. Fixed palette as classes so the page gets by without
   inline styles and style-src 'self' stays in place. */
.dot-gray    { background: #6b7280; }
.dot-blue    { background: #2563eb; }
.dot-teal { background: #0891b2; }
.dot-green   { background: #16a34a; }
.dot-yellow    { background: #ca8a04; }
.dot-orange  { background: #ea580c; }
.dot-red     { background: #dc2626; }
.dot-purple    { background: #7c3aed; }
.dot-pink    { background: #db2777; }

@media (prefers-color-scheme: dark) {
  .dot-gray    { background: #9ca3af; }
  .dot-blue    { background: #60a5fa; }
  .dot-teal { background: #22d3ee; }
  .dot-green   { background: #4ade80; }
  .dot-yellow    { background: #facc15; }
  .dot-orange  { background: #fb923c; }
  .dot-red     { background: #f87171; }
  .dot-purple    { background: #a78bfa; }
  .dot-pink    { background: #f472b6; }
}

/* --- Fixed sidebar from 55rem ------------------------------------------- */
@media (min-width: 55.0625rem) {
  html, body { height: 100%; }
  /* Only menu and content scroll, not the page itself. */
  body { display: flex; flex-direction: column; overflow: hidden; }
  .header { flex: 0 0 auto; }
  body > .notice { flex: 0 0 auto; }
  .page-body { flex: 1 1 auto; min-height: 0; }
  .sidebar { overflow-y: auto; overscroll-behavior: contain; }
  .content { overflow-y: auto; overscroll-behavior: contain; }
}

/* --- Desktop: the phone-only parts stay hidden ---------------------------- */
.tabbar, .drawer-head, .drawer-backdrop, .drawer-user,
.filter-more-toggle, .filter-more-label, .more-toggle, .more-label { display: none; }
.brand { display: inline-flex; align-items: center; gap: .45rem; }
.brand img { display: block; }

/* --- Phones and narrow windows ----------------------------------------------
   App layout: header at the top, the folders as a tab bar at the bottom,
   everything else in a drawer that slides in from the left. The page
   scrolls as a whole. env(safe-area-inset-*) keeps clear of the notch and
   the home indicator when installed as a web app (viewport-fit=cover). */
@media (max-width: 55rem) {
  :root { --tabbar-height: 3.6rem; }
  body { padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }

  .header {
    position: sticky; top: 0; z-index: 20;
    padding: calc(.5rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) .5rem calc(1rem + env(safe-area-inset-left));
  }
  .header .user { display: none; }
  .header .btn { padding: .35rem .65rem; font-size: .9rem; }

  .page-body { display: block; }
  .content { padding: 1rem calc(1rem + env(safe-area-inset-right)) 1.5rem calc(1rem + env(safe-area-inset-left)); }
  body > .notice { margin: .75rem 1rem 0; }
  h1 { font-size: 1.3rem; }

  /* Drawer */
  .sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
    width: min(20rem, 86vw); overflow-y: auto; overscroll-behavior: contain;
    padding: calc(.75rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    border-right: 1px solid var(--border);
    transform: translateX(-105%); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }
  .sidebar:target, .menu-open .sidebar {
    transform: none; visibility: visible;
    transition: transform .2s ease, visibility 0s;
    box-shadow: 0 0 2rem rgb(0 0 0 / .25);
  }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 .5rem; }
  .drawer-title { font-weight: 700; font-size: 1.1rem; }
  .drawer-close { font-size: 1.1rem; min-width: 2.75rem; min-height: 2.75rem; display: inline-grid; place-items: center; }
  .drawer-user { display: block; margin: 1rem 0 0; overflow-wrap: anywhere; }
  .nav-folders { display: none; }
  .sidebar .list a { padding: .65rem .75rem; }
  .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgb(0 0 0 / .4); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .sidebar:target ~ .drawer-backdrop, .menu-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

  /* Tab bar */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--bg-2); border-top: 1px solid var(--border);
    view-transition-name: tabbar;
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .15rem; min-height: var(--tabbar-height); padding: .3rem .1rem;
    color: var(--text-muted); text-decoration: none; font-size: .7rem; line-height: 1.1;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a span:not(.counter) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar svg {
    width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor;
    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  }
  .tabbar a.active { color: var(--accent); font-weight: 600; }
  .tabbar .counter { position: absolute; top: .3rem; left: calc(50% + .45rem); font-size: .65rem; }

  /* Filters: search plus a toggle for the rest */
  .filter { gap: .5rem; }
  /* Search and the toggle fill the first row together; the basis keeps
     the opened filters from moving up next to the search and squeezing it. */
  .filter-search { flex: 1 1 calc(100% - 7rem); min-width: 0; }
  .filter-field input:not([type=checkbox]), .filter-field select { width: 100%; }
  .filter-more-label { display: inline-block; flex: 0 0 auto; align-self: flex-end; margin: 0; font-size: .95rem; }
  /* input. raises the specificity above the general checkbox rule,
     which would otherwise give the hidden toggle a place in the row. */
  input.filter-more-toggle {
    display: block; position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none;
  }
  .filter-more-toggle:focus-visible + .filter-more-label { outline: 2px solid var(--accent); outline-offset: 2px; }
  .filter-more-toggle:checked + .filter-more-label { border-color: var(--accent); color: var(--accent); }
  .filter-extra { display: none; flex: 1 1 12rem; }
  .filter-more-toggle:checked ~ .filter-extra { display: block; }
  .filter-more-toggle:checked ~ .filter-buttons { display: flex; flex-wrap: wrap; gap: .5rem; flex-basis: 100%; }
  .filter-toggle label { padding-top: .25rem; }

  /* Touch targets */
  .btn { padding: .5rem .85rem; }
  .btn-small { padding: .35rem .6rem; }
  .bulk-action { gap: .4rem; }
  .bulk-action .btn { font-size: .9rem; padding: .4rem .65rem; }
  /* The bulk actions only appear once a mail is ticked; until then the
     bar is just "select all" and the list starts higher up. */
  @supports selector(:has(*)) {
    form:not(:has(input[name=mail]:checked)) > .bulk-action .btn { display: none; }
    form:has(input[name=mail]:checked) > .bulk-action {
      position: sticky; top: 3.4rem; z-index: 10; background: var(--bg);
    }
  }

  /* Mail view: subject, sender line, one row of actions, then the mail.
     The headers and the category wait behind "Details". */
  .back { margin: 0 0 .25rem; font-size: .9rem; }
  .mail-view h1 { font-size: 1.15rem; margin-bottom: .5rem; }
  .mail-meta { margin: 0 0 .5rem; font-size: .95rem; }
  .mail-meta .mail-date { display: block; margin: 0; }
  input.more-toggle { display: block; position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
  .more-label { display: inline-block; margin: 0 0 .5rem; }
  .more-toggle:focus-visible + .more-label { outline: 2px solid var(--accent); outline-offset: 2px; }
  .more-toggle:checked + .more-label { border-color: var(--accent); color: var(--accent); }
  .mail-details { display: none; }
  .more-toggle:checked ~ .mail-details { display: block; }
  .mail-headers { grid-template-columns: 5.5rem minmax(0, 1fr); gap: .15rem .6rem; font-size: .9rem; }
  .mail-headers dt { font-size: .85rem; }
  /* The actions stay on one line and scroll sideways instead of wrapping
     into a block that pushes the mail down. */
  .mail-actions { margin: 0 0 .5rem; }
  .mail-actions .row {
    flex-wrap: nowrap; overflow-x: auto; margin: 0; padding-bottom: .15rem;
    scrollbar-width: none;
  }
  .mail-actions .row::-webkit-scrollbar { display: none; }
  .mail-actions .btn { flex: 0 0 auto; font-size: .85rem; padding: .4rem .65rem; }
  .mail-view .tabs { margin-bottom: .5rem; }
  .mail-view .tab { padding: .3rem .65rem; font-size: .9rem; }
  .mail-view .notice { font-size: .9rem; margin: .5rem 0; }
  .mail-frame { height: calc(100dvh - 8rem); min-height: 20rem; }
  .mail-text { padding: .75rem; }
  .welcome-hint-actions { flex: 1 1 100%; }
  .welcome-hint .btn { flex: 1 1 auto; text-align: center; }
}

/* The mail list as cards: sender and date, subject below, then category
   and the quick actions. A table with six columns cannot fit a phone. */
@media (max-width: 40rem) {
  .table-wrap:has(> .mail-list) { overflow: visible; }
  .mail-list, .mail-list tbody { display: block; }
  .mail-list thead { display: none; }
  .mail-list tr {
    display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto;
    grid-template-areas: "sel sender date" "sel subject subject" "sel cat quick";
    column-gap: .6rem; row-gap: .1rem; padding: .7rem 0; border-bottom: 1px solid var(--border);
  }
  .mail-list td { display: block; padding: 0; border: 0; width: auto; }
  .mail-list .col-select { grid-area: sel; padding-top: .2rem; }
  .mail-list .col-sender { grid-area: sender; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .mail-list .col-sender .small { display: none; }
  .mail-list .col-date { grid-area: date; font-size: .8rem; align-self: center; justify-self: end; }
  /* Two blue links per card are too loud; the card reads as text. */
  .mail-list a { color: var(--text); }
  .mail-list .col-subject { grid-area: subject; font-weight: 400; color: var(--text); }
  .mail-list tr.unread .col-subject { font-weight: 600; }
  .mail-list .col-category { display: block; grid-area: cat; align-self: center; font-size: .8rem; font-weight: 400; color: var(--text-muted); }
  .mail-list .col-quick { grid-area: quick; display: flex; gap: .3rem; justify-content: flex-end; }
  /* Phones have no hover, so the buttons keep their frame. */
  .mail-list tr:not(:hover) .btn-quick, .mail-list .btn-quick { min-width: 2.5rem; min-height: 2.25rem; border-color: var(--border); }
}

/* --- Page changes ----------------------------------------------------------
   Every click loads a full page. With cross-document view transitions the
   browser cross-fades the content instead of blanking the window, and the
   header and sidebar, which look the same on every page, stay put.
   Browsers without support simply navigate as before. */
@view-transition { navigation: auto; }
.header { view-transition-name: header; }
.sidebar { view-transition-name: sidebar; }
::view-transition-group(root) { animation-duration: 120ms; }
::view-transition-group(header), ::view-transition-group(sidebar) { animation: none; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
