/* Fern web client and admin panel.
 *
 * Look: "Grove" (calm, three panes) or "Focus" (rail and cards), each in
 * light or dark. common.js sets on <html>:
 *   data-scheme  light | dark (resolved from the theme preference)
 *   data-style   grove | focus
 *   data-accent  green | blue | plum | clay | graphite
 *   data-density comfortable | compact
 * and --scale for the text size. */

:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-2: #eef2ee;
  --hover: #e9efe9;
  --line: #e2e7e1;
  --line-2: #dce3dc;
  --text: #17201a;
  --text-2: #26302a;
  --muted: #5b675e;
  --accent: #2e7d4f;
  --accent-strong: #1f5c39;
  --accent-2: #e6f2ea;
  --accent-line: #cfe3d6;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --danger-2: #fbe9e7;
  --warn: #8a5a00;
  --warn-2: #fff4d6;
  --star: #c98a00;
  --unread: #10170f;
  --shadow: 0 1px 2px rgba(23, 32, 26, .06), 0 6px 18px rgba(23, 32, 26, .07);
  --shadow-btn: 0 1px 2px rgba(23, 32, 26, .12), 0 6px 16px rgba(46, 125, 79, .22);
  --radius: 12px;
  --radius-sm: 9px;
  --scale: 1;
  --row-pad: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* Avatar colours: background / text pairs. */
  --av0: #dcefe3; --av0t: #1f5c39;
  --av1: #e1eafa; --av1t: #23477f;
  --av2: #f4e4f0; --av2t: #74305f;
  --av3: #fbe9e2; --av3t: #8a3a1f;
  --av4: #f6efd9; --av4t: #6b5212;
  --av5: #e5ecee; --av5t: #33494f;
  color-scheme: light;
}

/* Before the script has run, follow the system. */
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme]) { color-scheme: dark; --bg: #111613; --panel: #171d19; --text: #e4eae5; --line: #2a332d; }
}

:root[data-scheme="dark"] {
  --bg: #111613;
  --panel: #171d19;
  --panel-2: #1d2520;
  --hover: #222b25;
  --line: #2a332d;
  --line-2: #2f3a33;
  --text: #e4eae5;
  --text-2: #cbd4ce;
  --muted: #9aa79e;
  --accent: #5fbf86;
  --accent-strong: #8fd9ae;
  --accent-2: #1e3427;
  --accent-line: #2d4d39;
  --accent-text: #0b1a11;
  --danger: #f2b8b5;
  --danger-2: #3b1d1b;
  --warn: #f0c46a;
  --warn-2: #3a2f14;
  --star: #f0c46a;
  --unread: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 16px rgba(0, 0, 0, .3);
  --av0: #23362b; --av0t: #a6e8c2;
  --av1: #23324c; --av1t: #a9c3f5;
  --av2: #3a2636; --av2t: #eab4da;
  --av3: #3d2a22; --av3t: #f2b89e;
  --av4: #3a3220; --av4t: #f2d48a;
  --av5: #26302f; --av5t: #b6cdd2;
  color-scheme: dark;
}

/* Accents. */
:root[data-accent="blue"] { --accent: #2f6fb5; --accent-strong: #1f4f86; --accent-2: #e5eef9; --accent-line: #c9dbf0; }
:root[data-accent="plum"] { --accent: #7a4a9e; --accent-strong: #5a3378; --accent-2: #f1e9f7; --accent-line: #ddcbea; }
:root[data-accent="clay"] { --accent: #b5582f; --accent-strong: #8a3f1f; --accent-2: #fbebe3; --accent-line: #f0d0c0; }
:root[data-accent="graphite"] { --accent: #4a5560; --accent-strong: #2f373f; --accent-2: #eceff2; --accent-line: #d4dade; }
:root[data-scheme="dark"][data-accent="blue"] { --accent: #6fa8ec; --accent-strong: #a9c9f5; --accent-2: #1b2a3d; --accent-line: #2b4363; --accent-text: #0a1626; }
:root[data-scheme="dark"][data-accent="plum"] { --accent: #c093e6; --accent-strong: #dcc0f2; --accent-2: #2c2036; --accent-line: #48345a; --accent-text: #1b0f26; }
:root[data-scheme="dark"][data-accent="clay"] { --accent: #ec9a73; --accent-strong: #f6c2a8; --accent-2: #3a241a; --accent-line: #5c3a2a; --accent-text: #26110a; }
:root[data-scheme="dark"][data-accent="graphite"] { --accent: #b3bec8; --accent-strong: #d7dee4; --accent-2: #252b30; --accent-line: #3a434b; --accent-text: #111619; }

:root[data-density="compact"] { --row-pad: 7px; }

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: calc(14px * var(--scale)) / 1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
[hidden] { display: none !important; }
svg { flex: none; }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: var(--hover); color: var(--text); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .item:focus-visible, .msg:focus-visible, .chipbtn:focus-visible, .seg button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-2); color: var(--danger); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.icon-only { width: 36px; padding: 0; }
.btn.icon-only.small { width: 30px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .lbl { font-size: 13.5px; }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=datetime-local], input[type=number], input[type=url], select, textarea {
  width: 100%; min-width: 0; max-width: 100%; min-height: 38px; padding: 7px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 4px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.error { color: var(--danger); }
kbd { font: 12px var(--font); color: var(--muted); padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); }

/* Segmented control and pill chips. */
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.chipbtn {
  height: 32px; padding: 0 13px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chipbtn:hover { background: var(--hover); }
.chipbtn[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-2); color: var(--accent-strong); font-weight: 500; }

/* Avatars. */
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
  background: var(--av0); color: var(--av0t); user-select: none;
}
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.c1 { background: var(--av1); color: var(--av1t); }
.avatar.c2 { background: var(--av2); color: var(--av2t); }
.avatar.c3 { background: var(--av3); color: var(--av3t); }
.avatar.c4 { background: var(--av4); color: var(--av4t); }
.avatar.c5 { background: var(--av5); color: var(--av5t); }

/* ---------- Login ---------- */

.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-2), transparent 60%), var(--bg);
}
.login form {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand img { width: 32px; height: 32px; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; }
.brand .mark svg { width: 18px; height: 18px; }
.login h1 { font-size: 21px; margin: 18px 0 18px; letter-spacing: -.01em; }
.login .btn { width: 100%; margin-top: 6px; min-height: 42px; }

/* ---------- App shell ---------- */

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100%; overflow: hidden; }
.sidebar {
  border-right: 1px solid var(--line); background: var(--bg);
  display: flex; flex-direction: column; gap: 16px; min-height: 0; padding: 20px 14px 14px;
}
.sidebar .brand { padding: 0 6px; }
.compose-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  height: 46px; padding: 0 16px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer; box-shadow: var(--shadow-btn);
}
.compose-btn:hover { filter: brightness(1.06); }
.compose-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.compose-btn > span { display: flex; align-items: center; gap: 10px; }
.compose-btn svg { width: 18px; height: 18px; }
.compose-btn .key { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: rgba(255, 255, 255, .18); }
.sidebar > * { flex-shrink: 0; }
.nav {
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px;
}
.nav .item {
  text-decoration: none;
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 38px;
  padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: transparent;
  cursor: pointer; text-align: left; color: var(--text); flex: none;
}
.nav .item > span:not(.count) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .item { padding-left: calc(12px + var(--indent, 0) * 14px); min-width: 0; }
.nav .item > svg, .nav .item > .pmark, .nav .item > .dot { flex: none; }
.nav .item > span:not(.count) { min-width: 0; flex: 0 1 auto; }
.nav .item .count { flex: none; }
.nav .item .count.soft { color: var(--muted); font-weight: 600; }
.nav .item.more { display: none; }
.nav .item:hover { background: var(--hover); }
.nav .item.active { background: var(--accent-2); color: var(--accent-strong); font-weight: 600; }
.nav .item .count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--accent-strong); }
.nav .item.active .count { background: var(--accent); color: var(--accent-text); padding: 0 7px; border-radius: 9px; line-height: 18px; }
.nav .item svg { width: 18px; height: 18px; color: var(--muted); }
.nav .item.active svg { color: var(--accent); }
.nav .item .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent-line); flex: none; }
.nav .rule { display: none; }
/* Folding a group's folders, and choosing which stay in view. */
.nav .item.fold svg { width: 16px; height: 16px; }
.nav .item.pick[aria-pressed="false"] svg { opacity: .35; }
.nav .item.pick[aria-pressed="true"] svg { color: var(--accent); }
.nav .item.pick[aria-pressed="false"] > span:not(.count) { color: var(--muted); }
.nav .section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 12px 6px; }
.sidebar .storage { padding: 0 12px; font-size: 12px; color: var(--muted); }
.sidebar .storage .meter { height: 6px; margin-top: 6px; }
.account {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
}
.account .who { min-width: 0; flex: 1; }
.account .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .who span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.searchbox {
  flex: 1 1 320px; max-width: 640px; display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  margin: 0; font-weight: 400;
}
.searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.searchbox svg { width: 18px; height: 18px; color: var(--muted); }
.searchbox input[type=search] { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0; min-height: 0; }
.filters-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2e9e5e; }
.status.off::before { background: var(--warn); }

.panes { flex: 1; display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); min-height: 0; }
.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list .head { display: flex; align-items: center; gap: 8px; padding: 16px 20px 10px 20px; }
.list .head .titles { flex: 1; min-width: 0; }
.list .head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .head .sub { font-size: 12px; color: var(--muted); }
.list .items { overflow: auto; flex: 1; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.list .group { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.msg {
  display: flex; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: var(--row-pad) 12px; border-radius: var(--radius); cursor: pointer; color: var(--text); flex: none;
}
.msg:hover { background: var(--hover); }
.msg.active { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.msg .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg .l1, .msg .l2 { display: flex; gap: 8px; align-items: center; min-width: 0; }
.msg .from, .msg .subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .date { color: var(--muted); font-size: 12px; flex: none; }
.msg .prev { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .from, .msg.unread .subj { font-weight: 650; color: var(--unread); }
.msg .udot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--accent); }
.msg .flag { color: var(--star); flex: none; }
.msg .badge { flex: none; }
.msg .attchip {
  margin-top: 4px; align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 8px; border-radius: 6px; background: var(--panel-2); font-size: 12px; color: var(--text-2);
}
.msg .attchip svg { width: 13px; height: 13px; }
:root[data-density="compact"] .msg .avatar { width: 30px; height: 30px; font-size: 12px; }
:root[data-density="compact"] .msg .prev, :root[data-density="compact"] .msg .attchip { display: none; }
/* A row's checkbox for bulk actions (mail-bulk.js): a real checkbox over
 * the avatar, its box drawn by .tick. It shows on hover and focus, when the
 * row is checked, and on every row while any is checked. */
.msg .pick { position: relative; flex: none; align-self: flex-start; display: grid; place-items: center; user-select: none; }
.msg .pick-box {
  position: absolute; inset: -3px; z-index: 1; width: auto; height: auto; margin: 0;
  opacity: 0; cursor: pointer; appearance: none;
}
.msg .pick .tick {
  display: none; position: absolute; top: 50%; left: 50%; translate: -50% -50%;
  width: 18px; height: 18px; border: 2px solid var(--muted); border-radius: 5px; background: var(--panel);
}
.msg:hover .pick .avatar, .msg .pick:focus-within .avatar, .msg.checked .pick .avatar, .list.selecting .msg .pick .avatar { visibility: hidden; }
.msg:hover .pick .tick, .msg .pick:focus-within .tick, .msg.checked .pick .tick, .list.selecting .msg .pick .tick { display: block; }
.msg.checked .pick .tick { background: var(--accent); border-color: var(--accent); }
.msg.checked .pick .tick::after {
  content: ""; position: absolute; left: 4px; top: 0; width: 5px; height: 10px;
  border: solid var(--accent-text); border-width: 0 2px 2px 0; rotate: 45deg;
}
.msg .pick-box:focus-visible { outline: none; }
.msg .pick-box:focus-visible + .tick { outline: 2px solid var(--accent); outline-offset: 2px; }
.msg.checked, :root[data-style="focus"] .msg.checked { background: var(--accent-2); }
:root[data-style="focus"] .msg.checked { border-color: var(--accent-line); }
/* The bulk bar takes the heading's place (and its buttons') while rows are checked. */
.list.selecting .head > .btn { display: none; }
.list .bulk { flex: 1; min-width: 0; min-height: 46px; display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.list .bulk .pick.all { display: grid; place-items: center; width: 38px; height: 30px; flex: none; }
.list .bulk .select-all { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.list .bulk-count { font-weight: 600; white-space: nowrap; margin-right: auto; }
.list .bulk-acts { display: flex; gap: 2px; margin-left: auto; }
.list .bulk-acts .btn svg { color: var(--muted); }
.list .bulk-acts .btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.list .bulk-acts .btn[aria-pressed="true"] svg { color: var(--star); }
@media (pointer: coarse) { .list .bulk-acts .btn.icon-only.small { width: 40px; min-height: 40px; } }
.list .more { padding: 12px; text-align: center; }
/* The rows (a listbox) lay out as the scrolling box does. */
.list .rows { display: flex; flex-direction: column; gap: inherit; }
.list .rows:focus-visible { outline: none; }
/* "Empty Spam now" / "Empty Trash now" (mail-empty.js). */
.list .empty-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin: 0 20px 8px; padding: 8px 10px 8px 14px; border-radius: 10px; background: var(--panel-2); font-size: 13px; color: var(--muted); }
.list .empty-bar[hidden] { display: none; }
.list .empty-bar .note { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.list .empty-bar .note:empty { flex-basis: 0; }
.list .empty-bar .btn { margin-left: auto; }
.list .empty-bar .btn[aria-disabled="true"] { opacity: .6; cursor: default; }
:root[data-style="focus"] .list .empty-bar { margin: 0 4px 8px; }
/* Placeholder rows while a list without a copy loads (no layout jump: row height). */
.skeleton { display: flex; flex-direction: column; gap: 2px; }
.sk-row { display: grid; grid-template-columns: 36px 1fr; grid-template-rows: auto auto; gap: 6px 12px; padding: 12px 10px; align-items: center; }
.sk-row i { grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; background: var(--hover); }
.sk-row b { height: 10px; border-radius: 5px; background: var(--hover); width: 80%; }
.sk-row b.short { width: 55%; }
@media (prefers-reduced-motion: no-preference) {
  .sk-row i, .sk-row b { animation: sk-pulse 1.2s ease-in-out infinite alternate; }
}
@keyframes sk-pulse { from { opacity: .55; } to { opacity: 1; } }
.empty.load-error { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty.load-error svg { width: 22px; height: 22px; color: var(--danger, #b3261e); }
.empty.load-error .big { margin-bottom: 0; }
.reader .cards { display: block; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .big { display: block; font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 4px; }

.reader { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.reader .bar { display: flex; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.reader .bar .btn svg { color: var(--muted); }
.reader .bar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.reader .scroll { overflow: auto; flex: 1; }
.reader .inner { padding: 28px 40px 24px; max-width: 860px; }
.reader h1 { font-size: 24px; margin: 0 0 18px; line-height: 1.25; letter-spacing: -.015em; word-wrap: break-word; }
.sender { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 16px; }
.sender .who { flex: 1; min-width: 200px; }
.sender .who .name { font-weight: 600; margin-right: 8px; }
.sender .who .addr { color: var(--muted); word-break: break-all; }
.sender .who .when { font-size: 13px; color: var(--muted); }
.verified {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px;
  background: var(--accent-2); color: var(--accent-strong); font-size: 12px; font-weight: 600;
}
.verified svg { width: 14px; height: 14px; }
.verified.bad { background: var(--danger-2); color: var(--danger); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; margin: -6px 0 16px 58px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-word; }
.body-text { white-space: pre-wrap; word-wrap: break-word; font-size: calc(15px * var(--scale)); line-height: 1.65; color: var(--text-2); }
.body-html { width: 100%; border: 0; min-height: 200px; background: #fff; border-radius: 8px; }
.atts { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.att {
  display: inline-flex; gap: 12px; align-items: center; padding: 10px 14px 10px 10px; min-width: 220px; max-width: 360px;
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); font-size: 13px;
}
.att:hover { background: var(--hover); color: var(--text); }
.att .ext { width: 40px; height: 40px; border-radius: 10px; background: var(--av3); color: var(--av3t); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.att .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .sz { font-size: 12px; color: var(--muted); }
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.notice svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.back { display: none; }
.conv-msg { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; background: var(--panel); }
.conv-msg.open { padding-bottom: 16px; }
.conv-msg > :not(.conv-head) { margin-left: 18px; margin-right: 18px; }
.conv-head {
  display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px 18px;
  border: 0; background: transparent; cursor: pointer; text-align: left; color: var(--text); border-radius: 14px;
}
.conv-head:hover { background: var(--hover); }
.conv-from { font-weight: 600; flex: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.conv-head .date { margin-left: auto; flex: none; color: var(--muted); font-size: 12.5px; }
/* A single message reads as a page, not a card. */
.conv-single .conv-msg { border: 0; margin: 0; }
.conv-single .conv-msg > :not(.conv-head) { margin-left: 0; margin-right: 0; }
.conv-single .conv-head { display: none; }

.replybar { padding: 0 40px 28px; max-width: 860px; }
.replybox { border-radius: 14px; border: 1px solid var(--line-2); box-shadow: 0 1px 2px rgba(23, 32, 26, .05); overflow: hidden; }
.replybox button.prompt {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; cursor: text;
  padding: 14px 16px; color: var(--muted); font-size: 15px;
}
.replybox .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg); }

/* ---------- Compose and dialogs ---------- */

.overlay { position: fixed; inset: 0; background: rgba(10, 15, 10, .35); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; z-index: 20; overscroll-behavior: contain; }
.dialog {
  width: 100%; min-width: 0; max-width: 720px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; overflow-x: hidden;
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.dialog .dhead { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dialog .dhead h2 { margin: 0; font-size: 16px; flex: 1; }
.dialog .dbody { padding: 16px 18px; }
.dialog .dfoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* Send with its Schedule send half, joined. */
.send-split { display: inline-flex; }
.send-split .send-now { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.send-split .send-later { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(255, 255, 255, .35); padding-left: 8px; padding-right: 8px; }
.send-split .send-later svg { width: 16px; height: 16px; }
.err-text { color: var(--danger, #b3261e); min-height: 1.2em; margin: 6px 0 0; }
.sched-at { align-self: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose-grid { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px 10px; align-items: center; margin-bottom: 10px; }
.compose-grid label { margin: 0; color: var(--muted); font-weight: 500; }
.compose textarea { min-height: 260px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--panel-2); font-size: 12.5px; }
.chip > svg { width: 14px; height: 14px; color: var(--muted); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 30;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Pages (settings, admin) ---------- */

.page { overflow: auto; padding: 24px 28px 40px; background: var(--bg); flex: 1; min-height: 0; }
.page h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.page > .sub { color: var(--muted); margin: 0 0 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; margin-bottom: 18px; max-width: 980px; }
.card h2 { font-size: 16px; margin: 0 0 4px; }
.card > .sub { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-width: 980px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: 12.5px; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; max-width: 980px; }
.alert.warn { background: var(--warn-2); color: var(--warn); }
.alert.ok { background: var(--accent-2); color: var(--accent-strong); }

/* Settings: a section list beside the open section. */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; max-width: 1220px; }
.settings .snav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.settings .snav h1 { margin: 0 0 14px 12px; }
.settings .snav button {
  display: flex; align-items: center; gap: 12px; min-height: 38px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; text-align: left; color: var(--text);
}
.settings .snav button svg { width: 18px; height: 18px; color: var(--muted); }
.settings .snav button:hover { background: var(--hover); }
.settings .snav button[aria-current="true"] { background: var(--accent-2); color: var(--accent-strong); font-weight: 600; }
.settings .snav button[aria-current="true"] svg { color: var(--accent); }
.settings .spane > h2.stitle { font-size: 20px; margin: 4px 0 4px; letter-spacing: -.01em; }
.settings .spane > .sub { color: var(--muted); margin: 0 0 18px; }
.settings .card { max-width: 820px; }

/* Appearance choices. */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.choice {
  display: flex; flex-direction: column; gap: 10px; padding: 10px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--panel); cursor: pointer; text-align: left; color: var(--text);
}
.choice:hover { border-color: var(--accent-line); }
.choice[aria-pressed="true"] { border-color: var(--accent); }
.choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice .pv { height: 86px; border-radius: 9px; display: flex; gap: 5px; padding: 7px; overflow: hidden; }
.choice .pv i { display: block; border-radius: 4px; }
.choice b { font-weight: 600; }
.choice span { font-size: 12px; color: var(--muted); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.actions { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.badge.ok, .badge.pass { background: var(--accent-2); color: var(--accent-strong); }
.badge.warn, .badge.info, .badge.pending { background: var(--warn-2); color: var(--warn); }
.badge.bad, .badge.fail, .badge.failed { background: var(--danger-2); color: var(--danger); }
.record-value { font-family: var(--mono); font-size: 12px; word-break: break-all; max-width: 520px; }
pre.zone { background: var(--panel-2); padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 320px; }

/* ---------- Reading pane position ---------- */

/* Below the list. */
.app[data-pane="below"] .panes { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(160px, 38%) minmax(0, 1fr); }
.app[data-pane="below"] .list { border-right: 0; border-bottom: 1px solid var(--line); }
/* Off: the list fills the space and a message opens in its place. */
.app[data-pane="off"] .panes { grid-template-columns: minmax(0, 1fr); }
.app[data-pane="off"].reading .list { display: none; }
.app[data-pane="off"]:not(.reading) .reader { display: none; }
.app[data-pane="off"] .back { display: inline-flex; }
.app[data-pane="off"] .list .items { padding-left: max(10px, calc(50% - 480px)); padding-right: max(10px, calc(50% - 480px)); }

/* ---------- Focus style: an icon rail and cards ---------- */

:root[data-style="focus"] { --radius: 18px; }
:root[data-style="focus"] .app { grid-template-columns: 76px minmax(0, 1fr); }
:root[data-style="focus"] .sidebar { padding: 18px 10px; align-items: center; gap: 10px; }
:root[data-style="focus"] .sidebar .brand > span,
:root[data-style="focus"] .compose-btn .lbl,
:root[data-style="focus"] .compose-btn .key,
:root[data-style="focus"] .nav .item > span:not(.count),
:root[data-style="focus"] .nav .section,
:root[data-style="focus"] .sidebar .storage,
:root[data-style="focus"] .account .who { display: none; }
:root[data-style="focus"] .sidebar .brand { padding: 0; margin-bottom: 8px; }
:root[data-style="focus"] .compose-btn { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 14px; }
:root[data-style="focus"] .nav { align-items: center; margin: 0; padding: 0; gap: 6px; }
:root[data-style="focus"] .nav .item { width: 48px; min-height: 48px; padding: 0; justify-content: center; border-radius: 14px; position: relative; }
:root[data-style="focus"] .nav .item .count {
  position: absolute; top: 5px; right: 4px; margin: 0; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-size: 10.5px; line-height: 18px; text-align: center;
}
:root[data-style="focus"] .nav .item .dot { width: 14px; height: 14px; border-radius: 5px; }
:root[data-style="focus"] .nav .rule { display: block; width: 28px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }
:root[data-style="focus"] .account { flex-direction: column; padding: 0; border: 0; background: transparent; gap: 8px; }
:root[data-style="focus"] .topbar { border-bottom: 0; padding: 18px 28px 10px; }
:root[data-style="focus"] .searchbox { border-radius: 23px; height: 46px; }
:root[data-style="focus"] .panes { gap: 20px; padding: 6px 28px 24px; }
:root[data-style="focus"] .list { border: 0; }
:root[data-style="focus"] .list .head { padding: 4px 4px 12px; }
:root[data-style="focus"] .list .head h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
:root[data-style="focus"] .list .items { padding: 0 2px 10px; gap: 10px; }
:root[data-style="focus"] .msg { border: 1px solid var(--line); background: var(--panel); padding: 16px; border-radius: 18px; }
:root[data-style="focus"] .msg:hover { border-color: var(--accent-line); background: var(--panel); }
:root[data-style="focus"] .msg.active { border-color: var(--accent); box-shadow: var(--shadow); }
:root[data-style="focus"] .msg .avatar { width: 34px; height: 34px; font-size: 13px; }
:root[data-style="focus"] .reader { border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }
:root[data-style="focus"] .reader .bar { border-bottom: 0; padding: 14px 18px 0; }
:root[data-style="focus"] .reader .inner, :root[data-style="focus"] .replybar { margin: 0 auto; max-width: 760px; }
:root[data-style="focus"] .reader h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
:root[data-style="focus"] .body-text { font-size: calc(16px * var(--scale)); line-height: 1.75; }
:root[data-style="focus"] .app[data-pane="below"] .panes { grid-template-columns: minmax(0, 1fr); }
:root[data-style="focus"] .page { padding: 24px 32px 40px; }
:root[data-style="focus"] .card { border-radius: 20px; }

/* ---------- Icon rail (Focus style, or narrower than 980px) ----------
 * Set by mail.js as .app.rail. Only the main mailboxes show; "More" opens the
 * whole sidebar over the page. The rail never scrolls sideways, and scrolls
 * up and down without a scrollbar (a classic scrollbar would take the width
 * of its icons), fading at the edge that has more. */
.app.rail .nav { scrollbar-width: none; padding: 2px 0; }
.app.rail .nav::-webkit-scrollbar { display: none; }
.app.rail .nav.more-down { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
.app.rail .nav.more-up { -webkit-mask-image: linear-gradient(to top, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to top, #000 calc(100% - 28px), transparent); }
.app.rail .nav.more-up.more-down { -webkit-mask-image: linear-gradient(transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(transparent, #000 28px, #000 calc(100% - 28px), transparent); }
.app.rail .nav .item { padding-left: 0; padding-right: 0; flex: none; }
.app.rail .nav .extra:not(.item.active) { display: none; }
.app.rail .nav .item.more { display: flex; }
.app.rail .nav .item .count.soft { background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line); }
.app.rail .sidebar { min-width: 0; overflow: hidden; }
.app.rail .sidebar > * { flex: none; }
.app.rail .sidebar > .nav { flex: 1 1 0; }

/* "More": the whole sidebar, over the page. */
.scrim { display: none; }
.app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 14; background: rgba(10, 14, 12, .38); }
:root[data-scheme="dark"] .app.nav-open .scrim { background: rgba(0, 0, 0, .55); }
.app.rail .main { grid-column: 2; grid-row: 1; }
:root .app.rail.nav-open .sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 15; width: min(300px, calc(100vw - 48px));
  align-items: stretch; padding: 20px 14px 14px; gap: 16px; background: var(--bg); box-shadow: var(--shadow); border-right: 1px solid var(--line);
}
:root .app.rail.nav-open .sidebar .brand { padding: 0 6px; margin: 0; }
:root .app.rail.nav-open .sidebar .brand > span,
:root .app.rail.nav-open .sidebar .compose-btn .lbl,
:root .app.rail.nav-open .sidebar .nav .item > span:not(.count),
:root .app.rail.nav-open .sidebar .nav .section,
:root .app.rail.nav-open .sidebar .storage:not([hidden]),
:root .app.rail.nav-open .sidebar .account .who { display: revert; }
:root .app.rail.nav-open .sidebar .compose-btn { width: 100%; padding: 0 16px; justify-content: space-between; border-radius: var(--radius-sm); }
:root .app.rail.nav-open .sidebar .nav { align-items: stretch; margin: 0 -4px; padding: 0 4px; gap: 2px; -webkit-mask-image: none; mask-image: none; scrollbar-width: thin; }
:root .app.rail.nav-open .sidebar .nav .item { width: 100%; min-height: 40px; padding: 0 12px 0 calc(12px + var(--indent, 0) * 14px); justify-content: flex-start; border-radius: var(--radius-sm); }
:root .app.rail.nav-open .sidebar .nav .extra { display: flex; }
:root .app.rail.nav-open .sidebar .nav .section.extra { display: block; }
:root .app.rail.nav-open .sidebar .nav .rule { display: none; }
:root .app.rail.nav-open .sidebar .nav .item.more { display: none; }
:root .app.rail.nav-open .sidebar .nav .item .count { position: static; margin-left: auto; background: none; color: var(--accent-strong); min-width: 0; height: auto; padding: 0; }
:root .app.rail.nav-open .sidebar .nav .item.active .count { background: var(--accent); color: var(--accent-text); padding: 0 7px; border-radius: 9px; line-height: 18px; }
:root .app.rail.nav-open .sidebar .account { flex-direction: row; padding: 10px; border: 1px solid var(--line); background: var(--panel); }

/* ---------- Narrow screens ---------- */

/* Shown only on phones; declared before the media query that shows it. */
.menu-btn { display: none !important; }

@media (max-width: 1100px) {
  .panes { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .reader .inner { padding: 22px 26px 20px; }
  .replybar { padding: 0 26px 22px; }
  .filters-row .chipbtn:nth-child(n+3) { display: none; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  /* The rail look, whatever the style. */
  .sidebar { padding: 18px 10px; align-items: center; gap: 10px; }
  .sidebar .brand > span, .compose-btn .lbl, .compose-btn .key, .nav .item > span:not(.count), .nav .section, .sidebar .storage, .account .who { display: none; }
  .sidebar .brand { padding: 0; }
  .compose-btn { width: 48px; height: 48px; padding: 0; justify-content: center; }
  .nav { align-items: center; margin: 0; padding: 0; }
  .nav .item { width: 48px; min-height: 44px; padding: 0; justify-content: center; position: relative; }
  .nav .item .count { position: absolute; top: 3px; right: 2px; margin: 0; font-size: 10.5px; }
  .account { flex-direction: column; padding: 0; border: 0; background: transparent; }
  .panes, :root[data-style="focus"] .panes { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .app.reading .list { display: none; }
  .app:not(.reading) .reader { display: none; }
  .back { display: inline-flex; }
  .status { display: none; }
  /* Still two columns: a narrower list of sections beside the section. */
  .settings { grid-template-columns: 190px minmax(0, 1fr); gap: 16px; }
  .settings .snav button > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 640px) {
  .app, :root[data-style="focus"] .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .app.nav-open .sidebar {
    display: flex; position: fixed; inset: 0 22% 0 0; z-index: 15; box-shadow: var(--shadow); background: var(--bg);
    align-items: stretch; padding: 20px 14px 14px;
  }
  .app.nav-open .sidebar .brand > span, .app.nav-open .compose-btn .lbl, .app.nav-open .nav .item > span:not(.count),
  .app.nav-open .nav .section, .app.nav-open .sidebar .storage, .app.nav-open .account .who { display: revert; }
  .app.nav-open .compose-btn { width: 100%; padding: 0 16px; justify-content: space-between; }
  .app.nav-open .nav { align-items: stretch; }
  .app.nav-open .nav .item { width: 100%; padding: 0 12px; justify-content: flex-start; }
  .app.nav-open .nav .item .count { position: static; margin-left: auto; }
  .app.nav-open .account { flex-direction: row; padding: 10px; border: 1px solid var(--line); background: var(--panel); }
  .menu-btn { display: inline-flex !important; }
  .topbar, :root[data-style="focus"] .topbar { padding: 10px 12px; gap: 8px; }
  .searchbox { flex-basis: 0; height: 40px; }
  .filters-row { display: none; }
  .panes, :root[data-style="focus"] .panes { padding: 0; gap: 0; }
  :root[data-style="focus"] .reader { border-radius: 0; border: 0; }
  .list .head { padding: 12px 14px 8px; }
  .list .items { padding: 0 6px 80px; }
  .page, :root[data-style="focus"] .page { padding: 18px 16px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .reader .inner { padding: 16px 16px 14px; }
  .replybar { padding: 0 16px 20px; }
  .reader .bar .lbl { display: none; }
  .meta { margin-left: 0; }
  .fab {
    position: fixed; right: 18px; bottom: 18px; z-index: 12; width: 56px; height: 56px; border-radius: 18px; border: 0;
    background: var(--accent); color: var(--accent-text); display: grid; place-items: center; box-shadow: var(--shadow-btn); cursor: pointer;
  }
  .fab svg { width: 22px; height: 22px; }
  /* Writing on a phone: the whole screen, no margins around the dialog. */
  .overlay:has(> .dialog.compose) { padding: 0; place-items: stretch; }
  .dialog.compose { max-width: none; max-height: none; height: 100%; border-radius: 0; border: 0; }
  .compose-grid { grid-template-columns: 52px minmax(0, 1fr); }
  .app.reading .fab { display: none; }
}
@media (min-width: 641px) { .fab { display: none; } }

/* ---------- Contacts ---------- */
.page-head { align-items: center; margin-bottom: 4px; }
.page-head h1 { margin: 0; }
.contact-list { margin-top: 10px; }
.contact { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); }
.contact:first-child { border-top: 0; }
.contact .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-2); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.contact .who { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; font: inherit; }
.contact .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.contact .who:hover strong { color: var(--accent); }

/* ---------- Calendar ---------- */
.card.cal { max-width: 1200px; }
.card.cal > .row { align-items: center; margin-bottom: 10px; }
.card.cal h2 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-grid .dow { font-size: 12px; color: var(--muted); padding: 6px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.cal-grid .cell { min-height: 104px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-grid .cell:hover { background: var(--panel-2); }
.cal-grid .cell.other { background: var(--bg); color: var(--muted); }
.cal-grid .cell .num { font-size: 12px; font-weight: 600; padding: 2px 4px; align-self: flex-start; border-radius: 10px; }
.cal-grid .cell.today .num { background: var(--accent); color: var(--accent-text); }
.ev { display: block; width: 100%; text-align: left; font: inherit; font-size: 12px; color: var(--text); background: var(--accent-2); border: 0; border-left: 3px solid var(--accent); border-radius: 4px; padding: 2px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.ev .t { color: var(--muted); margin-right: 4px; }
.ev:hover { filter: brightness(0.96); }
.cal-grid .more { font-size: 11px; color: var(--muted); padding: 0 4px; }
.agenda { display: none; }
.agenda .aday { padding: 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.agenda .adate { font-weight: 600; font-size: 14px; }
.agenda .ev { font-size: 14px; padding: 6px 8px; }
@media (max-width: 640px) {
  .cal-grid { display: none; }
  .agenda { display: block; }
}

/* ---------- Address suggestions ---------- */
.ac { position: relative; min-width: 0; }
.ac input { width: 100%; }
.suggest { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 240px; overflow: auto; }
.suggest .opt { padding: 7px 10px; cursor: pointer; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .opt[aria-selected="true"], .suggest .opt:hover { background: var(--accent-2); }
.suggest .opt-sub { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.suggest-head { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); border-top: 1px solid var(--line); }
.suggest-group:first-child .suggest-head { border-top: 0; }
.suggest-hint { padding: 8px 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); white-space: normal; }
.suggest-hint:first-child { border-top: 0; }

/* ---------- Security ---------- */
.login .sub { color: var(--muted); font-size: 13px; margin: -8px 0 16px; }
.login .form-like { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.security .section-title { font-size: 18px; margin: 26px 0 12px; }
.qr-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.qr { background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--line); }
.secret, .app-password { font-size: 18px; letter-spacing: .06em; background: var(--panel-2); padding: 8px 12px; border-radius: 8px; user-select: all; overflow-wrap: anywhere; }
pre.codes { font-size: 16px; line-height: 1.7; background: var(--panel-2); padding: 12px 16px; border-radius: 8px; columns: 2; user-select: all; }
.list-table { width: 100%; border-collapse: collapse; }
.list-table td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.list-table tr:first-child td { border-top: 0; }
@media (max-width: 640px) {
  .list-table td.muted { display: block; padding-top: 0; border-top: 0; font-size: 12px; }
  pre.codes { columns: 1; }
}

/* ---------- Invitations ---------- */
.invite { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 14px; margin: 8px 0 14px; background: var(--panel); display: flex; flex-direction: column; gap: 4px; }
.invite-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.invite-when { font-weight: 500; }
.invite-warn { background: var(--panel-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--muted); }
.invite-status { font-size: 13px; margin-top: 4px; }
.invite-actions { margin-top: 6px; gap: 6px; }
.guest-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip.ans-accepted { background: var(--accent-2); color: var(--accent); }
.chip.ans-declined { text-decoration: line-through; color: var(--muted); }
.ev.cancelled { text-decoration: line-through; opacity: .7; }
.login .passkey-btn { margin-top: 10px; }
/* Filters */
.conds { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 8px; }
.cond select, .cond input[type="text"] { width: auto; }
.cond .grow input { width: 100%; }
#filters .check { margin: 6px 0; flex-wrap: wrap; }
#filters .check select, #filters .check input[type="text"], #filters .check input[type="email"] { width: auto; min-width: 0; flex: 1 1 140px; max-width: 260px; }
.filters tr.off td:not(:first-child) { opacity: .55; }
.filters td.actions { white-space: nowrap; text-align: right; }
textarea.sieve { width: 100%; min-height: 320px; font-size: 13px; line-height: 1.45; tab-size: 4; }
pre.sieve-view { max-height: 260px; overflow: auto; background: var(--soft, rgba(127,127,127,.08)); padding: 10px 12px; border-radius: 8px; font-size: 12.5px; white-space: pre-wrap; }
@media (max-width: 640px) { .cond { flex-wrap: wrap; } .filters td.actions { white-space: normal; } }
/* Storage */
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.meter-fill.warn, .warn-text { color: var(--danger, #b42318); }
.meter-fill.warn { background: var(--danger, #b42318); }

/* Composer */
.editor-wrap { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 10px; container-type: inline-size; }
.editor-tools { display: flex; flex-wrap: wrap; gap: 1px; padding: 4px; border-bottom: 1px solid var(--line); background: var(--panel-2); align-items: center; min-width: 0; }
.editor-tools .btn { min-width: 30px; }
.editor-tools .tool { padding: 3px 5px; gap: 2px; color: var(--text); }
.editor-tools .tool svg { width: 18px; height: 18px; }
.editor-tools .tool svg + svg, .editor-tools .tool-text + svg { width: 14px; height: 14px; color: var(--muted); margin-left: -1px; }
.editor-tools .tool[aria-pressed="true"] { background: var(--accent-2); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--accent-line); }
.editor-tools .tool[aria-disabled="true"] { opacity: .45; }
.editor-tools .tool[aria-expanded="true"] { background: var(--hover); }
.editor-tools .tool:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.tool-letter { font: 600 15px/1 Georgia, "Times New Roman", serif; width: 16px; text-align: center; }
.tool-text { font-size: 13px; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-icon { display: inline-flex; }
.tool-sep { width: 1px; align-self: stretch; margin: 5px 3px; background: var(--line); }
.colour-a { display: inline-flex; flex-direction: column; align-items: center; font: 600 15px/1 Georgia, "Times New Roman", serif; width: 16px; }
.colour-bar { display: block; width: 16px; height: 3px; margin-top: 2px; border-radius: 1px; background: currentColor; box-shadow: 0 0 0 1px var(--line); }
.editor-tools .more-btn { display: none; }
/* A narrow composer (a phone) keeps the common tools in view; the rest
   open under "More formatting options" on a row of their own. */
@container (max-width: 620px) {
  .editor-tools .more-btn { display: inline-flex; }
  .editor-tools .more-item, .is-rich .editor-tools .editor-mode { display: none; order: 2; }
  .editor-wrap.more-open .editor-tools .more-item:not(.tool-sep) { display: inline-flex; }
  .editor-wrap.is-rich.more-open .editor-tools .editor-mode { display: inline-flex; margin-left: auto; }
  .editor-wrap.more-open .editor-tools::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
  .editor-tools .tool-sep { display: none; }
  .editor-tools .tool-grow { display: none; }
  .editor-tools .more-btn { margin-left: auto; }
}
@media (pointer: coarse) { .editor-tools .tool { min-width: 40px; min-height: 40px; } }
/* Popovers: colours, emoji (menus share Fern.menu's look). */
.editor-pop .menu-items { max-height: 340px; }
.editor-pop .pop-title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 2px 2px 6px; }
.colour-cols { display: flex; flex-wrap: wrap; gap: 14px; padding: 4px; overflow-y: auto; }
.colour-col { display: flex; flex-direction: column; min-width: 0; }
.colour-none { justify-content: flex-start; margin-bottom: 6px; }
.swatches { display: grid; grid-template-columns: repeat(8, 20px); gap: 3px; }
.swatch { width: 20px; height: 20px; padding: 0; border: 1px solid rgba(127, 127, 127, .45); border-radius: 4px; cursor: pointer; }
.swatch:hover { transform: scale(1.12); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.editor-pop.sheet .swatches { grid-template-columns: repeat(8, 28px); gap: 5px; }
.editor-pop.sheet .swatch { width: 28px; height: 28px; }
.emoji-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 4px; overflow-x: auto; flex: none; }
.emoji-tab { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; font-size: 18px; cursor: pointer; }
.emoji-tab[aria-selected="true"] { background: var(--accent-2); box-shadow: inset 0 -2px 0 var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; overflow-y: auto; min-height: 0; max-height: 260px; overscroll-behavior: contain; }
.emoji-grid .menu-empty { grid-column: 1 / -1; }
.emoji { height: 36px; border: 0; border-radius: 8px; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; padding: 0; }
.emoji-tab:hover, .emoji:hover { background: var(--hover); }
.emoji-tab:focus-visible, .emoji:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.editor hr { border: 0; border-top: 1px solid var(--line-2); margin: 10px 0; }
/* Dark theme: highlighted text without a colour of its own is shown dark,
   as it will read for the recipient (colours chosen are sent as they are). */
:root[data-scheme="dark"] .editor [style*="background-color"]:not([style^="color"]):not([style*=" color"]):not([style*=";color"]) { color: #17201a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme]) .editor [style*="background-color"]:not([style^="color"]):not([style*=" color"]):not([style*=";color"]) { color: #17201a; }
}
.editor { min-height: 260px; max-height: 55vh; overflow: auto; padding: 10px 12px; outline: none; line-height: 1.5; word-wrap: break-word; }
.editor:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.editor img { max-width: 100%; height: auto; }
.editor blockquote { margin: 0 0 0 .8ex; border-left: 2px solid var(--line); padding-left: 1ex; color: inherit; opacity: .85; }
.editor p { margin: 0 0 .6em; }
.editor-wrap textarea.editor-plain { border: 0; border-radius: 0; min-height: 260px; resize: vertical; }
.notice.images { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.notice.images span { flex: 1 1 260px; }
.plain-list { list-style: none; padding: 0; margin: 6px 0 10px; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }

/* ---------- Connected accounts ---------- */
.pmark { display: inline-grid; place-items: center; flex: none; border-radius: 28%; color: #fff; font-weight: 700; font-size: 15px; line-height: 1; }
.nav .item .pmark { font-size: 10px; border-radius: 5px; }
.pmarks { display: flex; gap: 8px; margin-bottom: 14px; }
.accounts-empty { text-align: left; }
.account-card h2 { font-size: 17px; }
.wizard .dbody { padding: 22px 26px; }
.wizard .step { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-strong); }
.wizard .wtitle { font-size: 22px; letter-spacing: -.01em; margin: 4px 0 6px; }
.ptiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.ptile {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); cursor: pointer; text-align: left; color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.ptile:hover { border-color: var(--accent-line); box-shadow: var(--shadow); }
.ptile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.ptile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ptile > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.ptile > span:last-child > span { font-size: 12.5px; color: var(--muted); }
.howto { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.howto h2 { font-size: 15px; margin: 0 0 4px; }
.howto p { margin: 0 0 8px; color: var(--text-2); font-size: 13.5px; }
.howto ol { margin: 0; padding-left: 20px; font-size: 13.5px; }
.howto li { margin: 3px 0; }
.adv { margin-top: 4px; }
.adv summary { cursor: pointer; color: var(--accent-strong); font-weight: 500; font-size: 13.5px; padding: 4px 0; }
.srv-grid { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px 10px; align-items: center; margin-top: 8px; }
.srv-grid > span { font-size: 13px; color: var(--muted); }
.check-report { border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px 10px; margin-top: 14px; }
.check-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.check-row:last-of-type { border-bottom: 0; }
.check-row .mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }
.check-row .mark.ok { background: var(--accent-2); color: var(--accent-strong); }
.check-row .mark.bad { background: var(--danger-2); color: var(--danger); }
.check-row .muted { font-size: 13px; }
.success { text-align: center; padding: 20px 10px; }
.bigcheck { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent-2); color: var(--accent-strong); display: grid; place-items: center; font-size: 30px; font-weight: 700; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent-strong); cursor: pointer; text-decoration: underline; font: inherit; }
.btn.big { min-height: 46px; padding: 0 22px; font-size: 15px; }
.card.inset { background: var(--panel-2); max-width: none; }
.msg .acct { flex: none; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 12%, transparent); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; margin-left: 4px; }
@media (max-width: 640px) {
  .srv-grid { grid-template-columns: 1fr 1fr; }
  .srv-grid > span { grid-column: 1 / -1; }
  .wizard .dbody { padding: 16px; }
}

/* ---------- Contacts app ---------- */
.page:has(> .contacts-app) { padding: 0; overflow: hidden; display: flex; }
.contacts-app { display: grid; grid-template-columns: 240px minmax(280px, 360px) minmax(0, 1fr); flex: 1; min-height: 0; height: 100%; }
.cside { padding: 22px 14px; border-right: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.cside h1 { font-size: 22px; letter-spacing: -.01em; }
.citem { display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); cursor: pointer; text-align: left; width: 100%; }
.citem svg { width: 17px; height: 17px; color: var(--muted); }
.citem:hover { background: var(--hover); }
.citem[aria-current="true"] { background: var(--accent-2); color: var(--accent-strong); font-weight: 600; }
.citem[aria-current="true"] svg { color: var(--accent); }
.citem .count { font-size: 12px; color: var(--muted); font-weight: 500; }
.citem > span.grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csection { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; }
.cnote { font-size: 12px; padding: 2px 12px 8px; margin: 0; }
.dupnote { margin-top: 14px; padding: 12px; border-radius: var(--radius); background: var(--warn-2); color: var(--warn); font-size: 13px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.cmid { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 16px 0 0; }
.cmid .searchbox { margin: 0 14px 10px; flex: none; }
.clist { overflow: auto; flex: 1; padding: 0 8px 20px; }
.cletter { position: sticky; top: 0; background: var(--bg); padding: 8px 12px 4px; font-size: 12px; font-weight: 700; color: var(--accent-strong); z-index: 1; }
.crow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; text-align: left; color: var(--text); }
.crow:hover { background: var(--hover); }
.crow[aria-current="true"] { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.crow > .grow { display: flex; flex-direction: column; min-width: 0; }
.crow b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .grow > span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .flag { color: var(--star); }
.cdetail { overflow: auto; padding: 28px 36px 40px; background: var(--panel); min-width: 0; }
.cback { display: none; margin-bottom: 10px; }
.avatar.xl { width: 76px; height: 76px; font-size: 28px; }
.chead { display: flex; gap: 18px; align-items: center; margin-bottom: 16px; }
.chead h2 { margin: 0; font-size: 24px; letter-spacing: -.015em; }
.chip.fav { background: var(--warn-2); color: var(--warn); }
.cactions { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.cfields { margin: 0; max-width: 720px; }
.cfield { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cfield dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.cfield dd { margin: 0; display: flex; flex-direction: column; gap: 4px; word-break: break-word; }
.csources { margin-top: 18px; padding: 14px 16px; border-radius: var(--radius); background: var(--panel-2); max-width: 720px; }
.csources .chips { margin-top: 8px; }
.csub { font-size: 14px; margin: 24px 0 8px; }
.crecent { display: flex; flex-direction: column; gap: 2px; max-width: 720px; }
.crecent-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 0; border-radius: var(--radius-sm); background: transparent; text-align: left; cursor: pointer; color: var(--text); }
.crecent-row:hover { background: var(--hover); }
.crecent-row .grow { display: flex; flex-direction: column; min-width: 0; }
.crecent-row .grow span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cedit .erows { display: flex; flex-direction: column; gap: 6px; }
.erow { display: flex; gap: 6px; align-items: center; }
.erow input { flex: 1; min-width: 0; }
.erow.addr { flex-wrap: wrap; }
.erow.addr input:first-child { flex-basis: 100%; }
.erow.addr input { flex-basis: 20%; }
.mergetable td, .mergetable th { white-space: pre-line; vertical-align: top; }
.mergetable td.merged { background: var(--accent-2); color: var(--accent-strong); font-weight: 500; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; border: 2px dashed var(--line-2); border-radius: 14px; cursor: pointer; text-align: center; }
.dropzone svg { width: 26px; height: 26px; color: var(--accent); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-2); }
a.choice { text-decoration: none; }
.toast.undo { display: flex; gap: 12px; align-items: center; }
.toast.undo .btn { min-height: 26px; }
@media (max-width: 1100px) {
  .contacts-app { grid-template-columns: 200px minmax(240px, 300px) minmax(0, 1fr); }
  .cdetail { padding: 22px 22px 40px; }
}
@media (max-width: 980px) {
  .contacts-app { grid-template-columns: minmax(0, 1fr); }
  .cside { display: none; }
  .contacts-app:not(.showing) .cdetail { display: none; }
  .contacts-app.showing .cmid { display: none; }
  .cback { display: inline-flex; }
  .cmid::before { content: ""; }
}
.cmid-head { display: none; }
@media (max-width: 980px) {
  .cmid-head { display: flex; align-items: center; gap: 8px; padding: 0 14px 10px; }
  .cmid-head h1 { margin: 0; font-size: 22px; }
}
.toast.with-action { display: flex; align-items: center; gap: 14px; }
.toast.with-action .btn { min-height: 28px; background: transparent; color: inherit; border-color: currentColor; }
.offline-bar { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 40; background: var(--warn-2); color: var(--warn); padding: 6px 14px; border-radius: 0 0 10px 10px; font-size: 13px; box-shadow: var(--shadow); }

/* ---------- Menus (Fern.menu) ---------- */
.menu-scrim { position: fixed; inset: 0; z-index: 30; }
.menu {
  position: fixed; z-index: 31; display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px;
}
.menu-search { margin-bottom: 6px; flex: none; }
.menu-items { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 1px; min-height: 0; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; flex: none;
  padding: 0 10px 0 calc(10px + var(--indent, 0) * 14px); border: 0; border-radius: 8px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit;
}
.menu-item svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg { color: var(--danger); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { flex: none; font-size: 12px; color: var(--muted); }
.menu-rule { height: 1px; background: var(--line); margin: 5px 4px; flex: none; }
.menu-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.menu.sheet {
  left: 0; right: 0; bottom: 0; top: auto; max-height: min(70vh, 70dvh); border-radius: 18px 18px 0 0;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
}
.menu.sheet .menu-item { min-height: 46px; }
.menu-scrim:has(+ .menu.sheet) { background: rgba(10, 14, 12, .38); }

/* The account button at the foot of the sidebar: the person, then their menu. */
.account { padding: 6px; gap: 4px; }
.account-btn {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px 6px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit;
}
.account-btn:hover { background: var(--hover); }
.account-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.account-btn .who { display: block; min-width: 0; flex: 1; }
.app.rail:not(.nav-open) .account-btn { flex: none; padding: 0; justify-content: center; }

/* ---------- Settings on a phone: the list of sections, then one section ---------- */
.sback { display: none; }
.app.on-page .fab { display: none; }
@media (max-width: 640px) {
  .settings { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .settings .snav { position: static; flex-direction: column; flex-wrap: nowrap; gap: 2px; }
  .settings .snav h1 { margin: 0 0 10px; }
  .settings .snav button { min-height: 48px; }
  .settings .snav button[aria-current="true"] { background: transparent; color: var(--text); font-weight: 500; }
  .settings .snav button[aria-current="true"] svg { color: var(--muted); }
  .settings.index .spane { display: none; }
  .settings:not(.index) .snav { display: none; }
  .settings:not(.index) .sback { display: inline-flex; margin: 0 0 8px -8px; }
}
.compose-grid > [hidden] { display: none; }
.to-row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.to-row > input { flex: 1; min-width: 0; }
.to-row .copies { flex: none; color: var(--muted); }
.compose-grid > .ac:has(> input[hidden]) { display: none; }
.to-row > .ac { flex: 1; min-width: 0; }
.dialog:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }

/* The message toolbar fits its pane, whatever the window: labels go first,
   then the less used actions keep only their icons. */
.reader { container-type: inline-size; }
@container (max-width: 860px) { .reader .bar .sec .lbl { display: none; } }
@container (max-width: 560px) { .reader .bar .lbl { display: none; } }
/* A narrow reader pane: the bar stays one line; Reply all, Forward, Spam,
   Move, Mark read and Star are under "More actions". */
.reader .bar .more-actions { display: none; }
@container (max-width: 640px) {
  .reader .bar { flex-wrap: nowrap; }
  .reader .bar .ovf { display: none; }
  .reader .bar .more-actions { display: inline-flex; }
}
@media (max-width: 640px) {
  .dialog.compose .dfoot { flex-wrap: nowrap; gap: 6px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .dialog.compose .dfoot .btn { padding: 0 10px; white-space: nowrap; }
  .dialog.compose .dfoot .muted { display: none; }
}

/* ---------- Account marks: provider logos and owners' own icons ---------- */
.pmark-img { display: inline-block; flex: none; border-radius: 26%; object-fit: cover; }
.pmark { font-family: system-ui, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; overflow: hidden; }
.nav .item .pmark-img { border-radius: 5px; }
.app.rail:not(.nav-open) .nav .item .pmark-img { width: 22px; height: 22px; }
.icon-preview { display: flex; align-items: center; gap: 14px; padding: 12px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); min-width: 0; }
.icon-preview > div:not(.grow):not(.icon-chips) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-chips { display: flex; gap: 8px; align-items: center; }
.emoji-pick { font-size: 18px; min-width: 36px; padding: 0 6px; }
.colours .swatch.auto { position: relative; }
.colours .swatch.auto::after { content: "A"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; }
