/* Satellite Mail — base styles. Light and dark themes follow the OS setting.
   Every colour the app uses is a named variable in the two blocks below (light, then dark), so a
   settings page can override any of them by setting the same variable. */

:root {
    /* page and surfaces */
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --border: #e2e6ef;

    /* text: UI text is black 15px, small and secondary text gray 13px */
    --text: #000000;
    --muted: #5f6368;
    --text-size: 15px;
    --small-size: 13px;

    /* accents and states */
    --accent: #2f6bff;
    --accent-hover: #1f56e0;
    --accent-soft: #e9f0ff;
    --accent-2: #7cc4ff;
    --on-accent: #ffffff;       /* text on accent, danger and other strong backgrounds */
    --danger: #d92d20;
    --danger-soft: #fdeceb;
    --success: #12805c;
    --success-soft: #e6f6ee;
    --info: #3559c7;
    --info-soft: #eef3ff;
    --warning: #b54708;         /* "over 25 MB" attachment warning */
    --caution: #f5a524;         /* attachment of an unusual type */
    --star: #f5a524;

    /* the "Satellite Mail" lettering (header and sign-in page) */
    --brand: #57a3d4;
    --brand-shadow: 0 1px 0 rgba(0, 0, 0, .45), 0 2px 3px rgba(16, 40, 96, .35);

    /* shadows: a subtle one under all UI text, a stronger one under white text on dark backgrounds,
       and drop shadows under buttons and chips (sm), panes and cards, and menus, popovers and toasts (lg) */
    --text-shadow: 0 1px 1px rgba(0, 0, 0, .14);
    --text-shadow-strong: 0 1px 2px rgba(0, 0, 0, .6);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .18), 0 1px 4px rgba(16, 24, 40, .08);
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .09);
    --shadow-lg: 0 12px 40px rgba(16, 24, 40, .22);
    --bar-shadow: 0 2px 8px rgba(16, 24, 40, .10);
    --pane-shadow: 3px 0 10px rgba(16, 24, 40, .10);

    /* sidebar folders */
    --sidebar-bg: var(--surface-2);
    --folder-text: var(--text);
    --folder-hover-bg: #e2e6ef;
    --folder-active-bg: #357ec7;    /* the folder you are in */
    --folder-active-text: #ffffff;
    --folder-drop-bg: #1f4778;      /* a folder with a message dragged over it: clearly darker */
    --folder-drop-text: #ffffff;
    --folder-drop-ring: #0b2546;
    --count-bg: var(--accent);      /* unread count */
    --count-text: #ffffff;

    /* message list: rows alternate between two stripes, with a thin gray line between rows */
    --row-divider: #8a8a8a;
    --row-odd-bg: #d9f4ff;              /* owner's pick */
    --row-odd-hover-bg: #c4ebff;        /* a shade darker, so hover shows on the pale stripe */
    --row-odd-selected-bg: #a9dcfb;     /* a ticked row: deeper background plus an outline */
    --row-odd-ring: #0b1f4d;
    --row-odd-text: #000000;
    --row-odd-subject: #4b0f8c;
    --row-odd-name: #0a2f8a;
    --row-odd-small: #2f3540;           /* dates, ages, counts */
    --row-odd-star: #8a4100;
    --row-odd-text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
    --row-even-bg: #ffffff;             /* owner: rows alternate white and light blue */
    --row-even-hover-bg: #e6f4fd;
    --row-even-selected-bg: #cfe9fb;    /* a ticked row: light blue tint plus an outline */
    --row-even-ring: #0b1f4d;
    --row-even-text: #000000;
    --row-even-subject: #4b0f8c;
    --row-even-name: #0a2f8a;
    --row-even-small: #474e5c;
    --row-even-star: #8a4100;
    --row-even-text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
    --row-open-bg: #ffe08a;             /* the message open in the reading pane, on either stripe */
    --row-open-hover-bg: #ffd766;
    --row-open-selected-bg: #ffd766;
    --row-open-ring: #0b1f4d;
    --row-open-text: #000000;
    --row-open-subject: #4b0f8c;
    --row-open-name: #0a2f8a;
    --row-open-small: #3b3b3b;
    --row-open-star: #8a4100;
    --row-open-text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
    --row-unread-bar: #ef6c00;          /* left edge of unread rows */
    --row-unread-bg: #000000;           /* owner: unread mail is black with light blue text */
    --row-unread-hover-bg: #1c1c1c;
    --row-unread-selected-bg: #14283b;
    --row-unread-ring: #ffd54a;
    --row-unread-text: #a3dcff;
    --row-unread-subject: #a3dcff;
    --row-unread-name: #4da3ff;         /* the person link stays blue, bright enough to read on black */
    --row-unread-small: #8cc4e8;
    --row-unread-star: #ffc94d;
    --row-unread-text-shadow: 0 1px 2px rgba(0, 0, 0, .8);

    /* subjects and links to people outside the list (reading pane, admin page) */
    --subject: #5b1aa6;
    --person: #1a4fd6;

    /* breadcrumbs above the list */
    --crumbs-bg: var(--surface);
    --crumb-link: #1a4fd6;

    /* message body frame, and the compose editor, which stays light: it previews what recipients see */
    --frame-bg: #ffffff;
    --editor-bg: #ffffff;
    --editor-text: #1b2230;
    --editor-link: #1f5fe0;
    --editor-quote-line: #cccccc;
    --editor-quote-text: #4a5568;
    --editor-rule: #d5dbe6;

    --radius: 12px;
    --logo-cut: var(--surface);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1220;
        --surface: #141a2a;
        --surface-2: #1a2134;
        --border: #262f48;
        --text: #e6e9f2;
        --muted: #a3acc0;
        --accent: #5b8cff;
        --accent-hover: #7ca3ff;
        --accent-soft: #1c2847;
        --danger: #f97066;
        --danger-soft: #361c1f;
        --success: #47cd89;
        --success-soft: #12301f;
        --info: #8eaaff;
        --info-soft: #1a2442;
        --warning: #fdb022;
        --brand-shadow: 0 1px 0 rgba(0, 0, 0, .9), 0 2px 4px rgba(0, 0, 0, .7);
        --text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
        --text-shadow-strong: 0 1px 2px rgba(0, 0, 0, .85);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45), 0 1px 4px rgba(0, 0, 0, .3);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
        --bar-shadow: 0 2px 10px rgba(0, 0, 0, .45);
        --pane-shadow: 3px 0 12px rgba(0, 0, 0, .45);
        --folder-hover-bg: #262f48;
        --folder-drop-bg: #03060d;
        --folder-drop-ring: #7ca3ff;
        --crumb-link: #8fb8ff;
        --row-divider: #56607a;
        --row-odd-bg: #285a80;
        --row-odd-hover-bg: #1f4866;
        --row-odd-selected-bg: #1d4565;
        --row-odd-ring: #ffd54a;
        --row-odd-text: #f4f7fc;
        --row-odd-subject: #e3c8ff;
        --row-odd-name: #bfe3ff;
        --row-odd-small: #d3dae5;
        --row-odd-star: #ffc94d;
        --row-odd-text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
        --row-even-bg: #1c3466;
        --row-even-hover-bg: #284889;
        --row-even-selected-bg: #152a54;
        --row-even-ring: #ffd54a;
        --row-even-text: #ffffff;
        --row-even-subject: #e3c8ff;
        --row-even-name: #bfe3ff;
        --row-even-small: #ccd5e5;
        --row-even-star: #ffc94d;
        --row-even-text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
        --row-open-bg: #5a4708;
        --row-open-hover-bg: #66520b;
        --row-open-selected-bg: #66520b;
        --row-open-ring: #ffd54a;
        --row-open-text: #fffaf0;
        --row-open-subject: #f0dcff;
        --row-open-name: #cfeaff;
        --row-open-small: #eadfc4;
        --row-open-star: #ffd54a;
        --row-open-text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
        --row-unread-bar: #ff9a3c;
        --subject: #d9b8ff;
        --person: #8fb8ff;
        color-scheme: dark;
    }
}

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

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font: var(--text-size)/1.5 var(--font);
    text-shadow: var(--text-shadow);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }

.muted { color: var(--muted); }
.small { font-size: var(--small-size); }
.mono { font-family: var(--mono); }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.no-js .js-only { display: none; }

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* ---- controls -------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font: 500 var(--text-size)/1 var(--font);
    text-decoration: none;
    text-shadow: var(--text-shadow);
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .user-option:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); text-shadow: var(--text-shadow-strong); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.is-active { background: var(--accent-soft); color: var(--accent); box-shadow: var(--shadow-sm); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--small-size); border-radius: 8px; }
.btn-block { width: 100%; height: 42px; }

input[type=text], input[type=password], input[type=email], select, textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-shadow: none;
    transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 12px; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; margin: 0 0 6px; padding: 0; color: var(--muted); font-size: var(--small-size); font-weight: 600; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--small-size);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.badge-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.alert {
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: var(--text-size);
    box-shadow: var(--shadow-sm);
    transition: opacity .4s;
}
.alert + .alert { margin-top: 8px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert.is-fading { opacity: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 16px;
}
.card h2 { margin-bottom: 14px; }

.logo { width: 28px; height: 28px; color: var(--accent); flex: none; }

/* ---- app shell ------------------------------------------------------- */

/* A flex column, not a grid: the flash row is optional, and with a fixed grid the content
   slid into the auto-sized flash row whenever there was no flash, so the mail view collapsed. */
body.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}
body.app > .topbar, body.app > .flashes { flex: none; }

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 58px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--bar-shadow);
    position: relative;
    z-index: 5;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--brand);
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    margin-right: 8px;
}
.brand span, .login-brand h1 { color: var(--brand); text-shadow: var(--brand-shadow); letter-spacing: .01em; }
.topbar-nav { display: flex; gap: 4px; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-user form { margin: 0; }
.who { color: var(--muted); font-size: var(--small-size); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

.flashes { padding: 12px 16px 0; }
.app .flashes { padding-bottom: 12px; }
.main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}
.main > .mail { flex: 1 1 auto; min-height: 0; }

.page { width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head form { margin: 0; }
.stack { display: grid; gap: 10px; margin: 0; }

.toasts {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 100;
    display: grid;
    gap: 8px;
    justify-items: center;
    pointer-events: none;
}
.toast {
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--text);
    color: var(--surface);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-size);
    text-shadow: none;
    transition: opacity .4s;
}
.toast-error { background: var(--danger); color: var(--on-accent); text-shadow: var(--text-shadow-strong); }
.toast.is-fading { opacity: 0; }

/* ---- mail: folders | list | reader ------------------------------------ */

/* No message open: the list gets the whole width. Message open: three panes.
   The breadcrumbs run above the list and the reader; the sidebar starts right under the header. */
.mail {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "side crumbs" "side list";
    min-height: 0;
}
.mail.has-message {
    grid-template-columns: 232px clamp(300px, 30%, 460px) minmax(0, 1fr);
    grid-template-areas: "side crumbs crumbs" "side list reader";
}
.folders { grid-area: side; }
.crumbs { grid-area: crumbs; }
.list { grid-area: list; }
.reader { grid-area: reader; }

.crumbs {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: baseline;
    gap: 2px 8px;
    min-width: 0;
    padding: 8px 16px;
    background: var(--crumbs-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--bar-shadow);
    font-size: var(--text-size);
}
.crumbs-label { flex: none; color: var(--muted); font-size: var(--small-size); }
.crumbs-list { display: flex; flex-wrap: wrap; align-items: baseline; min-width: 0; margin: 0; padding: 0; list-style: none; }
.crumbs-list li { display: flex; align-items: baseline; min-width: 0; max-width: 100%; }
.crumbs-list li + li::before { content: "›"; flex: none; margin: 0 8px; color: var(--muted); }
.crumbs-list a { color: var(--crumb-link); text-decoration: none; overflow-wrap: anywhere; }
.crumbs-list a:hover { text-decoration: underline; }
.crumbs-list a[aria-current="page"] { color: var(--text); font-weight: 700; }
.crumb-subject span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--subject); font-weight: 700; }

.folders {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: auto;
    padding: 12px 8px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    box-shadow: var(--pane-shadow);
    position: relative;
    z-index: 2;
}
/* The signed-in address: under the "Satellite Mail" lettering, above Inbox. */
.account {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 4px;
    padding: 2px 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: var(--text-size);
    font-weight: 600;
    line-height: 1.3;
}
.account-avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-size: var(--small-size);
    font-weight: 700;
    text-shadow: var(--text-shadow-strong);
    box-shadow: var(--shadow-sm);
}
.account-address { min-width: 0; overflow-wrap: break-word; }
.route-mail .topbar .who { display: none; } /* the sidebar shows it */
.folder-nav { display: flex; flex-direction: column; gap: 2px; }
.folder {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--folder-text);
    text-decoration: none;
    font-size: var(--text-size);
    transition: background .1s, box-shadow .1s;
}
.folder[data-depth="1"] { padding-left: 26px; }
.folder[data-depth="2"] { padding-left: 40px; }
.folder[data-depth="3"], .folder[data-depth="4"] { padding-left: 54px; }
.folder:hover { background: var(--folder-hover-bg); }
.folder.is-active {
    background: var(--folder-active-bg);
    color: var(--folder-active-text);
    font-weight: 700;
    text-shadow: var(--text-shadow-strong);
    box-shadow: var(--shadow-sm);
}
/* "Inbox(51)": the name shortens with … when the sidebar is narrow, the total always shows */
.folder-label { display: flex; min-width: 0; }
.folder-total { flex: none; }
.folder.has-unseen .folder-label { font-weight: 700; }
/* A message dragged over a folder darkens it until the drag leaves, drops or ends. */
.folder.is-drop-target {
    background: var(--folder-drop-bg);
    color: var(--folder-drop-text);
    text-shadow: var(--text-shadow-strong);
    box-shadow: inset 0 0 0 2px var(--folder-drop-ring), var(--shadow-sm);
}
.mail.is-dragging .folder:not(.is-active):not(.is-drop-target) { box-shadow: inset 0 0 0 1px var(--border); }
.folder-icon { width: 20px; text-align: center; font-size: 15px; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { margin-left: auto; padding: 0 7px; border-radius: 999px; background: var(--count-bg); color: var(--count-text); font-size: var(--small-size); font-weight: 700; line-height: 20px; text-shadow: var(--text-shadow-strong); box-shadow: var(--shadow-sm); }
.folder.is-active .count { background: var(--folder-active-text); color: var(--folder-active-bg); text-shadow: none; }

/* "New folder" opens inline: the sidebar scrolls, so a floating popover would be clipped. */
.folders details.popover > .popover-body {
    position: static;
    width: auto;
    margin: 4px 0 8px;
    box-shadow: none;
}
.folder-menu > summary { list-style: none; }
.folder-menu .popover-body form + form { padding-top: 10px; border-top: 1px solid var(--border); }
.new-folder > summary { list-style: none; justify-content: flex-start; width: 100%; color: var(--muted); }
.new-folder > summary:hover { color: var(--text); }
.folders-foot { margin-top: auto; padding: 8px 8px 0; }
.folders-foot p { margin: 0; }
.folders-foot p + p { margin-top: 6px; }
@media (hover: none) { .folders-hint { display: none; } }

.list { display: flex; flex-direction: column; min-height: 0; overflow: auto; background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--pane-shadow); position: relative; z-index: 1; }
.mail:not(.has-message) .list { border-right: 0; }
.list-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--bar-shadow);
}
.list-title { display: flex; align-items: center; gap: 12px; }
.list-title > div:first-of-type { flex: 1; min-width: 0; }
.list-head h1 { font-size: 18px; }
.list-head .muted { font-size: var(--small-size); }
.check-all, .msg-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.pager { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.bulk-bar { display: none; align-items: center; flex-wrap: wrap; gap: 6px; }
.list.has-selection .bulk-bar, .no-js .bulk-bar { display: flex; }
.bulk-count { font-size: 13px; font-weight: 600; color: var(--accent); margin-right: 4px; }
.move-to { display: inline-flex; align-items: center; gap: 6px; }
.move-to select { width: auto; max-width: 200px; height: 30px; padding: 0 8px; font-size: 13px; }

/* Rows alternate between two stripes, each with its own text colours, divided by a thin gray line.
   A row keeps its colours in --r-* properties, so the open/ticked/hover states can swap them. */
.messages { list-style: none; margin: 0; padding: 0; }
.msg-row {
    --r-bg: var(--row-odd-bg);
    --r-hover: var(--row-odd-hover-bg);
    --r-selected: var(--row-odd-selected-bg);
    --r-ring: var(--row-odd-ring);
    --r-text: var(--row-odd-text);
    --r-subject: var(--row-odd-subject);
    --r-name: var(--row-odd-name);
    --r-small: var(--row-odd-small);
    --r-star: var(--row-odd-star);
    --r-shadow: var(--row-odd-text-shadow);
    position: relative;
    display: flex;
    align-items: stretch;
    background: var(--r-bg);
    color: var(--r-text);
    text-shadow: var(--r-shadow);
    border-bottom: 1px solid var(--row-divider);
}
.msg-row:nth-child(even) {
    --r-bg: var(--row-even-bg);
    --r-hover: var(--row-even-hover-bg);
    --r-selected: var(--row-even-selected-bg);
    --r-ring: var(--row-even-ring);
    --r-text: var(--row-even-text);
    --r-subject: var(--row-even-subject);
    --r-name: var(--row-even-name);
    --r-small: var(--row-even-small);
    --r-star: var(--row-even-star);
    --r-shadow: var(--row-even-text-shadow);
}
.msg-row.is-unread {
    --r-bg: var(--row-unread-bg);
    --r-hover: var(--row-unread-hover-bg);
    --r-selected: var(--row-unread-selected-bg);
    --r-ring: var(--row-unread-ring);
    --r-text: var(--row-unread-text);
    --r-subject: var(--row-unread-subject);
    --r-name: var(--row-unread-name);
    --r-small: var(--row-unread-small);
    --r-star: var(--row-unread-star);
    --r-shadow: var(--row-unread-text-shadow);
}
.msg-row.is-open {
    --r-bg: var(--row-open-bg);
    --r-hover: var(--row-open-hover-bg);
    --r-selected: var(--row-open-selected-bg);
    --r-ring: var(--row-open-ring);
    --r-text: var(--row-open-text);
    --r-subject: var(--row-open-subject);
    --r-name: var(--row-open-name);
    --r-small: var(--row-open-small);
    --r-star: var(--row-open-star);
    --r-shadow: var(--row-open-text-shadow);
}
.msg-row.is-selected { background: var(--r-selected); box-shadow: inset 0 0 0 2px var(--r-ring); }
.msg-row:hover { background: var(--r-hover); }
.msg-row.is-unread::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 5px;
    background: var(--row-unread-bar);
}
.msg-row.is-dragging { opacity: .45; }
.msg-check { display: flex; align-items: center; padding: 0 2px 0 14px; cursor: pointer; }
.msg {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "from date" "subject date";
    gap: 2px 12px;
    padding: 11px 16px 12px 10px;
    color: inherit;
    text-decoration: none;
}
.msg:focus-visible { outline: 2px solid var(--r-ring); outline-offset: -3px; }
.mail:not(.has-message) .msg {
    grid-template-columns: minmax(150px, 260px) minmax(0, 1fr) auto;
    grid-template-areas: "from subject date";
    align-items: center;
    padding-top: 10px;
    padding-bottom: 10px;
}
.msg[draggable="true"] { cursor: pointer; }
/* names blue and underlined like links (a click writes to them), subjects bold purple, dates small */
.msg-from { grid-area: from; font-size: var(--text-size); color: var(--r-name); }
.msg-person { text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.msg-person:hover { text-decoration-thickness: 2px; }
.msg-person:focus-visible { outline: 2px solid var(--r-ring); outline-offset: 1px; border-radius: 3px; }
.msg-person.is-plain { text-decoration: none; cursor: inherit; }
.msg-to-label, .msg-more { color: var(--r-small); font-size: var(--small-size); }
.msg-to-label { margin-right: 4px; }
.msg-more { margin-left: 4px; }
.msg-row.is-unread .msg-person { font-weight: 700; }
.msg-subject { grid-area: subject; color: var(--r-subject); font-size: var(--text-size); font-weight: 700; }
/* "11 Oct · 1 day 2 hours ago": on one line in the wide list, stacked on the right in narrow ones */
.msg-date {
    grid-area: date;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-around;
    color: var(--r-small);
    font-size: var(--small-size);
    line-height: 1.3;
    white-space: nowrap;
}
.msg-date .date-sep { display: none; }
.mail:not(.has-message) .msg-date { display: block; align-self: center; }
.mail:not(.has-message) .msg-date .date-sep { display: inline; }
.msg-from, .msg-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.is-broken .msg-subject { color: var(--r-text); font-weight: 400; font-style: italic; }
.flag { color: var(--star); }
.msg-row .flag { color: var(--r-star); }
.answered { color: var(--muted); }
.msg-row .answered { color: var(--r-small); }
.drag-ghost {
    position: fixed;
    top: -200px;
    left: -200px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font: 600 var(--small-size) var(--font);
    box-shadow: var(--shadow-sm);
}

.reader { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.reader-head { padding: 18px 24px 14px; border-bottom: 1px solid var(--border); }
.reader-head h2 { font-size: 20px; margin-bottom: 10px; color: var(--subject); overflow-wrap: anywhere; }
.reader-head .back { display: none; margin: -4px 0 8px -8px; }
.meta { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 2px 12px; margin: 0; font-size: var(--text-size); }
.meta dt { color: var(--muted); font-size: var(--small-size); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
/* People are links that start a new message to them (reading pane, admin page). */
a.person { color: var(--person); text-decoration: underline; text-underline-offset: 2px; }
a.person:hover { text-decoration-thickness: 2px; }
.person-name { font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.actions form { margin: 0; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 12px 24px 0; }
.attachments a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    font-size: var(--small-size);
    box-shadow: var(--shadow-sm);
}
.attachments a:hover { border-color: var(--accent); }
.body-frame { flex: 1; width: 100%; min-height: 240px; border: 0; margin-top: 12px; background: var(--frame-bg); }

/* ---- compose ---------------------------------------------------------- */

.compose-page { max-width: 1100px; }
.compose { padding: 0; overflow: visible; }
.compose-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.compose-head h1 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-row { display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.compose-row:focus-within { background: var(--surface-2); }
.compose-label { flex: none; width: 64px; color: var(--muted); font-size: var(--text-size); }
.compose-static { line-height: 44px; }
.compose-row input { height: 44px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.compose-row input:focus { box-shadow: none; }
.plain-body {
    display: block;
    min-height: 340px;
    padding: 16px 20px;
    border: 0;
    border-radius: 0;
    font: 15px/1.6 var(--font);
    resize: vertical;
}
.plain-body:focus { box-shadow: none; }
.compose-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 14px 14px;
}
.attach { position: relative; overflow: hidden; }
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.attach-meter { font-size: var(--small-size); min-width: 0; }
.attach-meter.is-big { color: var(--warning); }
.attach-chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 12px 20px; border-top: 1px solid var(--border); }
.attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 4px 4px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    font-size: var(--small-size);
    box-shadow: var(--shadow-sm);
}
.attach-chip.is-unknown { border-color: var(--caution); background: color-mix(in srgb, var(--caution) 12%, var(--surface)); }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.attach-size { color: var(--muted); white-space: nowrap; }
.attach-remove {
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.attach-remove:hover { background: var(--danger-soft); color: var(--danger); }
.drop-hint { display: none; }
.compose.is-file-over { outline: 3px dashed var(--accent); outline-offset: 4px; }
.compose.is-file-over .drop-hint {
    display: block;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    text-align: center;
}

/* Rich-text editor. The writing area stays light in dark mode: it previews what recipients will see. */
.editor { position: relative; }
.editor-toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--bar-shadow);
}
.tb {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 32px;
    height: 32px;
    padding: 0 7px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font: 600 14px/1 var(--font);
    text-shadow: var(--text-shadow);
    cursor: pointer;
}
.tb:hover { background: var(--border); box-shadow: var(--shadow-sm); }
.tb[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.tb svg { width: 18px; height: 18px; }
.tb-small { font-size: 11px; }
.tb-quote { font: 700 20px/1 Georgia, serif; margin-top: 6px; }
.tb-clear { font-family: Georgia, serif; }
.tb-sep { width: 1px; height: 22px; margin: 0 6px; background: var(--border); }
.tb-spacer { flex: 1; }
.tb-select { width: auto; height: 32px; padding: 0 6px; font-size: 13px; }
.tb-color { flex-direction: column; gap: 1px; padding-top: 2px; }
.tb-color input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.tb-letter { font-size: 14px; line-height: 1; }
.tb-hl { font-size: 12px; }
.swatch { width: 16px; height: 4px; border-radius: 2px; background: currentColor; }
.tb-html {
    padding: 0 10px;
    border-color: var(--border);
    background: var(--surface);
    color: var(--accent);
    font: 700 13px/1 var(--mono);
}
.tb-html:hover { border-color: var(--accent); background: var(--accent-soft); }
.editor-area {
    min-height: 340px;
    padding: 16px 20px;
    background: var(--editor-bg);
    color: var(--editor-text);
    color-scheme: light;
    font: 15px/1.6 Arial, Helvetica, sans-serif;
    text-shadow: none;
    overflow-wrap: anywhere;
    outline: none;
}
.editor-area:focus { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.editor-area a { color: var(--editor-link); }
.editor-area img { max-width: 100%; height: auto; }
.editor-area blockquote { margin: 0 0 0 .8ex; padding-left: 1ex; border-left: 2px solid var(--editor-quote-line); color: var(--editor-quote-text); }
.editor-area table { border-collapse: collapse; max-width: 100%; }
.editor-area hr { border: 0; border-top: 1px solid var(--editor-rule); margin: 12px 0; }
.html-marker {
    display: inline-block;
    width: 3.4em;
    height: 1.3em;
    margin: 0 2px;
    vertical-align: text-bottom;
    border: 2px dashed var(--accent);
    border-radius: 4px;
    background: var(--accent-soft);
    animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }
.html-panel {
    position: absolute;
    z-index: 5;
    display: grid;
    gap: 8px;
    width: min(560px, calc(100% - 16px));
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.html-panel-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.html-panel textarea { min-height: 150px; font: 13px/1.5 var(--mono); resize: vertical; }
.html-panel-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- admin ------------------------------------------------------------ */

.create-form { display: grid; gap: 12px; max-width: 680px; }
.address-input { display: flex; align-items: center; gap: 8px; }
.address-input input { flex: 1 1 40%; }
.address-input select { flex: 1 1 55%; }
.at { color: var(--muted); font-size: 18px; }
.password-input { display: flex; gap: 8px; }
.password-input input { flex: 1; }
.create-form > .btn { justify-self: start; }

details.domain { border-top: 1px solid var(--border); }
details.domain:first-of-type { border-top: 0; }
details.domain > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 4px;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
}
details > summary::-webkit-details-marker { display: none; }
details.domain > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.domain[open] > summary::before { transform: rotate(90deg); }

.mailbox-list { list-style: none; margin: 0 0 12px; padding: 0; }
.mailbox { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 9px; }
.mailbox:hover { background: var(--surface-2); }
.mailbox-address { overflow-wrap: anywhere; }
.mailbox-actions { display: flex; gap: 6px; flex: none; }

details.popover { position: relative; }
details.popover > summary { list-style: none; }
.popover-body {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 10;
    display: grid;
    gap: 10px;
    width: min(360px, 86vw);
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.popover-body p { margin: 0; }
.popover-body .field { margin: 0; }
.popover-body > .btn { justify-self: start; }

/* ---- admin: load mail from another server (import) --------------------- */

.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.import .card h3 { font-size: var(--text-size); margin: 0 0 10px; }
.import .card p { margin: 0 0 10px; }
.import .card .small-head { margin: 22px 0 8px; color: var(--muted); font-size: var(--small-size); text-transform: uppercase; letter-spacing: .04em; }
.steps { display: grid; gap: 6px; margin: 8px 0 14px; padding-left: 26px; }
.import details > summary { list-style: none; cursor: pointer; color: var(--accent); font-weight: 600; margin: 6px 0; width: fit-content; }
.import details > summary::before { content: "▸ "; color: var(--muted); }
.import details[open] > summary::before { content: "▾ "; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; max-width: 680px; }
.inline-form .field { flex: 1 1 320px; margin: 0; }

.import-form { display: grid; gap: 4px; max-width: 680px; }
.import-form > .btn { justify-self: start; margin-top: 6px; }
.import-form > .alert { margin-bottom: 12px; }
.choices, .group { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices legend { padding: 0; }
.choice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 4px; accent-color: var(--accent); }
.choice > span { display: grid; gap: 2px; }
.server-row { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 8px; }
.import .field .muted.small { display: block; margin-top: 4px; }
.field-note { margin: -8px 0 14px !important; }
.is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }

.job-list { list-style: none; margin: 0; padding: 0; }
.job-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--border); }
.job-row:first-child { border-top: 0; }
.job-row > a { flex: 1; min-width: 0; display: grid; color: var(--text); text-decoration: none; }
.job-row > a:hover .job-route { color: var(--accent); }
.job-route { font-weight: 600; overflow-wrap: anywhere; }
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.job-head h2 { margin: 0; font-size: 17px; }
.job-head p { margin: 4px 0 0 !important; }
.job-message { margin-bottom: 14px; overflow-wrap: anywhere; }

.pill {
    flex: none;
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--small-size);
    font-weight: 700;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}
.pill-running { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill-done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.pill-signin, .pill-ready { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill-paused, .pill-dest_password { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); color: var(--warning); border-color: transparent; }
.pill-error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.signin { display: grid; gap: 10px; justify-items: start; }
.signin > * { margin: 0 !important; }
.signin .actions { width: 100%; }
.code-box { padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); box-shadow: var(--shadow-sm); }
.code-box .steps { margin: 0 0 8px; }
.user-code {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font: 700 20px/1.2 var(--mono);
    letter-spacing: .12em;
    overflow-wrap: anywhere;
}
.help-list { margin: 6px 0 0; }
.help-list dt { margin-top: 10px; font-weight: 600; }
.help-list dd { margin: 2px 0 0; }

.table-wrap { overflow-x: auto; }
.folder-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: var(--text-size); }
.folder-table th { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: var(--small-size); font-weight: 600; text-align: left; }
.folder-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.folder-table .num, .folder-table .nowrap { text-align: right; white-space: nowrap; }
.folder-table .nowrap { text-align: left; }
.folder-table .check { width: 32px; }
.folder-table td.why { min-width: 12em; overflow-wrap: break-word; }   /* server words wrap between words */
.folder-table input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.progress { height: 12px; overflow: hidden; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 1px 2px rgba(16, 24, 40, .12); }
.progress-bar { width: 0; height: 100%; background: var(--accent); transition: width .4s; }
.progress-main { margin: 10px 0 2px !important; font-size: 17px; font-weight: 600; }
.progress-block p { margin-top: 2px; margin-bottom: 2px; }
.folder-progress { columns: 2 260px; margin: 0; padding: 0; list-style: none; font-size: var(--text-size); }
.folder-progress li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; break-inside: avoid; }
.folder-progress li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.folder-progress li.is-done > span:first-child::before { content: "✓ "; color: var(--success); }
.folder-progress li.is-copying > span:first-child { font-weight: 700; }
.log ul { display: grid; gap: 2px; margin: 0 0 8px; padding: 0; list-style: none; font-size: var(--small-size); overflow-wrap: anywhere; }
.continue-form { margin-top: 12px; }
.import .actions { align-items: center; }
.continue-form .field { max-width: 420px; }
.skips, .more-folders { margin-top: 12px; }

.error-page .card { max-width: 480px; margin: 10vh auto 0; text-align: center; }

/* ---- login ------------------------------------------------------------ */

body.bare {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%),
        var(--bg);
}
.login { width: min(460px, 100% - 32px); padding: 32px 0; }
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 32px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .logo { width: 52px; height: 52px; }
.login-brand h1 { font-size: 26px; font-weight: 700; margin-top: 8px; }
.login-brand p { margin: 6px 0 0; color: var(--muted); font-size: var(--small-size); }
.login-card .flashes { padding: 0; margin-bottom: 16px; }
.login-card > .alert { margin-bottom: 16px; }
.login-foot { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: var(--small-size); }

.users { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.user-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.user-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font: 500 var(--text-size) var(--font);
    text-align: left;
    text-shadow: var(--text-shadow);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color .12s, background .12s;
}
.user-option:hover { border-color: var(--accent); }
.user-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}
.user-option[aria-pressed="true"] .avatar { background: var(--accent); color: var(--on-accent); text-shadow: var(--text-shadow-strong); }
.password-step { animation: rise .18s ease-out; }
.password-step strong { color: var(--text); }

@keyframes rise {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* ---- responsive ------------------------------------------------------- */

@media (max-width: 1100px) {
    .mail { grid-template-columns: 200px minmax(0, 1fr); }
    /* A message open on a mid-size screen replaces the list (Back returns to it). */
    .mail.has-message { grid-template-columns: 200px minmax(0, 1fr); grid-template-areas: "side crumbs" "side reader"; }
    .mail.has-message .list { display: none; }
    .reader-head .back { display: inline-flex; }
    .account { gap: 8px; font-size: 14px; } /* the narrower sidebar still fits "@domain" on one line */
    .account-avatar { display: none; }
    .mail:not(.has-message) .msg { grid-template-columns: minmax(120px, 200px) minmax(0, 1fr) auto; }
}

@media (max-width: 860px) {
    .topbar { gap: 8px; padding: 0 12px; }
    .brand span, .who { display: none; }
    .mail { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "side" "crumbs" "list"; }
    .mail.has-message { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "crumbs" "reader"; }
    .crumbs { padding: 6px 12px; font-size: var(--small-size); }
    /* the address, then "Space left" (beside it when both fit, else on the next line), then the folder strip */
    .folders { flex-flow: row wrap; align-items: center; gap: 4px 12px; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
    .account { flex: 1 1 auto; }
    .folders-foot { order: 1; margin: 0 0 0 auto; padding: 0; }
    .folders-foot .disk-space { margin: 0; padding: 0 4px 6px; }
    .folder-nav { order: 2; flex: 1 0 100%; min-width: 0; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
    /* a strip that scrolls sideways: every folder keeps its full "Name(total)" label */
    .folder, .folder[data-depth] { flex: none; padding: 6px 12px; white-space: nowrap; }
    .new-folder, .folders-hint { display: none; }
    .account { padding: 0 4px 6px; border-bottom: 0; font-size: var(--small-size); }
    .account-avatar { display: grid; width: 22px; height: 22px; font-size: 11px; }
    .list { border-right: 0; }
    .mail:not(.has-message) .msg {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "from date" "subject date";
    }
    .mail:not(.has-message) .msg-date { display: flex; align-self: stretch; }
    .mail:not(.has-message) .msg-date .date-sep { display: none; }
    .mail.has-message .folders { display: none; }
    .reader-head { padding: 14px 16px 12px; }
    .attachments { padding: 12px 16px 0; }
    .address-input { flex-wrap: wrap; }
    .mailbox { flex-wrap: wrap; }
    .card { padding: 16px; }
    .login-card { padding: 24px 20px; }
    .compose-page { padding: 0; }
    .compose { border-radius: 0; border-left: 0; border-right: 0; }
    .tb-sep { display: none; }
    .choices, .server-row { grid-template-columns: minmax(0, 1fr); }
    .job-head { flex-wrap: wrap; }
}

/* A 390 px phone: Compose, Mail, Admin and Sign out still fit in the top bar */
@media (max-width: 430px) {
    .topbar-nav .btn, .topbar-user .btn { padding: 0 10px; }
    .folder-table .size { display: none; }     /* skipped messages: Folder, Date and Why are what matter */
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
