/* ==========================================================================
   Labour Life practice system: emails.css. Owner: mail (M8). SPEC 7.6.1 to 7.6.3.
   Mailboxes admin, the email lists, the email page. Class prefix em-.

     Admin, Mailboxes (views/admin-mailboxes.js)
       .em-two (__s)  .em-box-open  .em-box-status  .em-box-err      cells of the list
       .em-form  .em-parts  .em-pane  .em-form-h  .em-form-state     the add and edit form
       .em-folders  .em-folder-add  .em-folder-list  .em-folder      folders to read
       .em-test (__l)                                                the answer of Test connection
       .em-sends  .em-send (__who)                                   who sends from the mailbox
       .em-sig  .em-sig-modal  .acct-sig (__h)                       the signature (26 Oct 2026)
     Email lists (views/emails.js)
       .em-tools  .em-boxpick (__a __n)  .em-boxsel  .em-lists       mailbox chooser and the three lists
       .em-list  .em-c-*  .em-subj (__t __s)  .em-clip               the table and its cells
       .em-who (__t)  .em-dot                                        the sender, and the dot of an unread email
       .em-chips  .em-chip  .em-acts  .em-act                        link chips and the two row buttons
       .em-inbox-tools  .em-list-note                                the tools of Inbox, the line of Outbox and Deleted
       .em-imp                                                       the small red "!" of an important email (27 Oct 2026)
       .em-subj__d (__dw)  .em-sync (__t, .is-spinning)  .em-checked how a row of Deleted was deleted, Send/receive (27 Oct 2026)
       .em-draft__open  .em-draft__mode  .em-list--drafts            the Drafts list (5 Nov 2026)
     One email (views/email.js), one column at full width since 27 Oct 2026
       .em-page  .em-top (__back)                                    the column, the way back
       .em-band (__top __subject __when __people __row __from __addr)  the dark band: subject, date, From, To, CC
       .em-pchips  .em-pchip (--more)  .em-way (--received --sent)   people as chips, Received or Sent
       .em-bar                                                       the one bar of actions
       .em-delstate (__l)                                            deleted by whom or in Outlook (27 Oct 2026)
       .em-row  .em-label (__none)                                   a labelled row: Attachments, Filed under
       .em-attchips  .em-attc (.is-off, __b __open __i __n __z __ok __menu __state)   attachments as chips
       .em-links  .em-fchips  .em-fchip (__a __k __c __n __s __x)    Filed under as chips
       .em-bodybox  .em-imgbar (__b)  .em-frame  .em-body  .em-text  the body
       .em-conv  .em-convlist  .em-conv__*                           the conversation
       .em-save (__f)  .em-fixed  .em-fullbody  .em-history
       .em-atts__body  .em-saveall  .em-save (__files __lead __h __list __i __t __n __why)   Save all (5 Nov 2026)
       .em-foldbar  .em-fold                                         Show the earlier emails (5 Nov 2026)
     Night mode (decision 494; the email screens had a dark mode of their own, decision 466, until then)
       html.is-dark .em-band                                         the band of an email at night, at the end of this file
     Attachments on a trail (components/email-trail.js)
       .em-attlist  .em-att (__i __t __n __s __b __saved)            the rows of an email opened on a trail

   Phone first: the base styles are the phone. Tokens only, no raw colours:
   the night values of the tokens are in tokens.css (html.is-dark), for the
   whole Hub.
   ========================================================================== */

/* ---------- shared ---------- */

.em-two { display: grid; gap: 2px; min-width: 0; text-align: left; }
.em-two__s { font-size: var(--fs-sm); font-weight: 400; color: var(--ink-mute); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.em-h { margin: 0 0 var(--s3); font-size: var(--fs-h3); }
.em-fixed { display: flex; align-items: center; min-height: var(--control-h); font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Admin, Mailboxes: the list ---------- */

.em-box-open { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.em-box-open:hover .em-two > span:first-child { text-decoration: underline; text-underline-offset: 2px; }
.em-box-status { display: grid; gap: var(--s2); justify-items: start; min-width: 0; }
.em-box-err { max-width: 34rem; padding: var(--s2) var(--s3); overflow-wrap: anywhere; }

/* ---------- Admin, Mailboxes: the form ---------- */

.em-form { min-width: 0; }
.em-parts { margin-bottom: var(--s4); }
.em-pane { min-width: 0; }
.em-form-h { margin: var(--s2) 0 var(--s3); padding-top: var(--s4); border-top: 1px solid var(--line); font-size: var(--fs-lg); }
.em-form-state { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.em-form-state > p { margin: 0; }

.em-folders { display: grid; gap: var(--s3); min-width: 0; }
.em-chip-t { overflow-wrap: anywhere; }
.em-folder-add { display: flex; flex-wrap: wrap; gap: var(--s2); }
.em-folder-add > .input { flex: 1 1 180px; min-width: 0; }
.em-folder-list {
  display: grid; max-height: 320px; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
}
.em-folder + .em-folder { border-top: 1px solid var(--line); }
.em-folder .check__t { overflow-wrap: anywhere; }
.em-folder.is-never { color: var(--ink-mute); cursor: default; }

.em-test {
  display: grid; gap: var(--s2); margin-top: var(--s4); padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--sunken);
}
.em-test__l { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); margin: 0; }
.em-test__l > span:last-child { min-width: 0; overflow-wrap: anywhere; }

.em-sends { display: grid; min-width: 0; }
.em-sends > p { margin: 0; }
.em-send { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 var(--s4); padding: var(--s2) 0; border-top: 1px solid var(--line); }
.em-send:first-child { border-top: 0; }
.em-send__who { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 520px) {
  .em-send { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; }
}

/* The signature with formatting and pictures (26 Oct 2026, components/signature-editor.js): the
   box is .rte of compose.css. In the mailbox form, in its own dialog, and on My account. */
.em-sig { gap: var(--s1); }
.em-sig .rte__area { min-height: 8em; }
.em-sig-modal { display: grid; gap: var(--s3); min-width: 0; }
.em-sig-modal > p { margin: 0; }
.acct-sig { display: grid; gap: var(--s2); margin: 0 0 var(--s4); padding: 0 0 var(--s4); border-bottom: 1px solid var(--line); }
.acct-sig:focus { outline: none; }
.acct-sig__h { margin: 0; font-size: var(--fs-lg); }
.acct-sig > p { margin: 0; }

/* ---------- the email lists ---------- */

.em-tools { min-width: 0; }
.em-boxpick__a { overflow: hidden; text-overflow: ellipsis; }
.em-boxpick__n {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--sunken); color: var(--ink-soft); font-size: var(--fs-label);
}
.em-boxsel { width: auto; max-width: 100%; }

.em-subj { display: grid; gap: 2px; min-width: 0; }
.em-subj__t { font-weight: 400; overflow-wrap: anywhere; }
.em-subj__s {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font-size: var(--fs-sm); line-height: var(--lh-snug); overflow-wrap: anywhere;
}
.em-clip { display: inline-grid; place-items: center; color: var(--ink-soft); }
/* A task's tag holds its title since 12 Nov 2026 (decision 473; Jose: "Nou gee hy net die task number"): one line,
   cut short with an ellipsis at about 44 characters or the width of its place, the tooltip holds all of it.
   The row of tags asks only for the width a tag had before, a code and a reference (contain: inline-size and
   min-width: 16ch), so a long title never widens the Subject or the Filed column and squeezes the others: the
   tags take the width the column has. inline-block, not inline-flex: an ellipsis needs the text to be the
   box's own. */
.em-chips { display: flex; flex-wrap: wrap; gap: var(--s1); min-width: 16ch; contain: inline-size; }
.em-chip {
  display: inline-block; max-width: min(100%, 44ch); padding: 2px var(--s2);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--sunken);
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; vertical-align: top;
}
.em-acts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--s2); }
.em-act { padding: 0 var(--s2); line-height: 1.15; }
.em-list tr.is-leaving { opacity: .5; }
.em-list .em-c-who { overflow-wrap: anywhere; }

/* On a phone a row is a card: who and when, the subject, the snippet, then the two buttons. */
@media (max-width: 719px) {
  .em-list .tbl--collapse tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px var(--s2); align-items: baseline; }
  .em-list .tbl--collapse td[data-k] { display: block; min-width: 0; }
  .em-list .tbl--collapse td[data-k]::before { display: none; }
  .em-list .tbl--collapse td.is-empty { display: none; }
  .em-list .tbl--collapse td.em-c-who { grid-column: 1; grid-row: 1; padding: 0; font-size: var(--fs-body); }
  .em-list .tbl--collapse td.em-c-files { grid-column: 2; grid-row: 1; align-self: center; }
  .em-list .tbl--collapse td.em-c-date { grid-column: 3; grid-row: 1; font-size: var(--fs-sm); color: var(--ink-mute); }
  .em-list .tbl--collapse td.em-c-subject { grid-column: 1 / -1; grid-row: 2; }
  .em-list .tbl--collapse td.em-c-links { grid-column: 1 / -1; grid-row: 3; padding-top: var(--s1); }
  .em-list .tbl--collapse td.em-c-acts { grid-column: 1 / -1; grid-row: 4; padding-top: var(--s2); }
  .em-list .em-c-who .tbl__a { display: block; padding: var(--s1) 0; }
}
@media (min-width: 720px) {
  .em-list .em-c-who { width: 22%; }
  .em-list .em-c-files, .em-list .em-c-date, .em-list .em-c-acts { width: 1%; white-space: nowrap; }
  .em-list .em-c-links { width: 14%; }
  .em-acts { display: flex; justify-content: flex-end; }
  .em-act { white-space: nowrap; padding: 0 var(--s3); }
}
@media (min-width: 720px) and (pointer: fine) {
  .em-act { min-height: var(--control-h-sm); font-size: var(--fs-sm); }
}

/* ---------- one email ---------- */

/* 27 Oct 2026 (Jose: "the mail itself is cramped", the HUB's email page as
   the example): one column at the whole width of the window, in the order
   the way back, the band, the bar of actions, the attachments, Filed under,
   the body, the conversation. A phone stacks the same order. */
.em-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); min-width: 0; }
.em-page > section { min-width: 0; }
.em-page > section[hidden] { display: none; }
/* The way back on the left. In a tab of its own, which has no top bar, the day or night button stands on the right (decision 494). */
.em-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-width: 0; }
.em-top > .theme-sw { flex: none; margin-left: auto; }
/* In a tab of its own (27 Oct 2026): a quiet line instead of the way back. */
.em-top__solo { margin: 0; }
.em-top__back { margin-bottom: 0; }

/* The dark band, in the coal of the top bar: the subject and on the right the
   date, then From (with Received or Sent), To, CC, BCC and Sent by. */
.em-band {
  display: grid; gap: var(--s3); min-width: 0;
  padding: var(--s4); border-radius: var(--r-md);
  background: var(--chrome-bg); color: var(--chrome-text);
}
.em-band__top { display: grid; gap: var(--s2); min-width: 0; }
.em-band__subject { margin: 0; color: var(--chrome-text); font-size: var(--fs-h2); line-height: var(--lh-snug); overflow-wrap: anywhere; }
.em-band__when { margin: 0; color: var(--chrome-soft); font-size: var(--fs-sm); }
.em-band__people { display: grid; gap: var(--s2); margin: 0; min-width: 0; }
.em-band__row { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); gap: var(--s3); align-items: baseline; min-width: 0; }
.em-band__row > dt { color: var(--chrome-soft); font-size: var(--fs-sm); font-weight: 600; }
.em-band__row > dd { margin: 0; min-width: 0; }
.em-band__from { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); min-width: 0; }
.em-band__addr { font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 720px) {
  .em-band { padding: var(--s5) var(--s6); }
  .em-band__top { grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: var(--s5); }
  .em-band__when { padding-top: var(--s2); text-align: right; white-space: nowrap; }
  .em-band__row { grid-template-columns: 4.5rem minmax(0, 1fr); }
}

/* To, CC and BCC as chips on the band, each "Name <address>". */
.em-pchips { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); min-width: 0; }
.em-pchips:focus { outline: none; }
.em-pchip {
  display: inline-flex; align-items: center; max-width: 100%; padding: 2px var(--s2);
  border: 1px solid var(--chrome-line); border-radius: var(--r-pill); background: var(--chrome-bg-2);
  color: var(--chrome-text); font-size: var(--fs-sm); line-height: var(--lh-snug); overflow-wrap: anywhere;
}
button.em-pchip--more { min-height: 28px; font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
button.em-pchip--more:hover { background: var(--chrome-hover); }
button.em-pchip--more:focus-visible { outline: 2px solid var(--focus-on-dark); outline-offset: 2px; }
@media (pointer: coarse) { button.em-pchip--more { min-height: var(--tap); } }

/* Received or Sent (27 Oct 2026): an arrow and the word, never colour alone. */
.em-way {
  display: inline-flex; align-items: center; gap: 2px; flex: none;
  padding: 1px var(--s2) 1px var(--s1); border-radius: var(--r-pill);
  font-size: var(--fs-label); font-weight: 600; line-height: 1.3; white-space: nowrap;
}
.em-way--received { background: var(--info-bg); color: var(--info-ink); }
.em-way--sent { background: var(--success-bg); color: var(--success-ink); }

/* The one bar of actions under the band. Each button keeps its 44px. */
.em-bar { display: flex; flex-wrap: wrap; gap: var(--s2); }
.em-bar > .btn { flex: 1 1 auto; }
@media (min-width: 720px) { .em-bar > .btn { flex: 0 0 auto; } }

/* A labelled row: Attachments, Filed under. The label sits on the left from 720px. */
.em-row { display: grid; gap: var(--s2); min-width: 0; }
.em-label {
  margin: 0; color: var(--ink-soft);
  font: 600 var(--fs-label)/1.25 var(--font-display); letter-spacing: var(--track-label); text-transform: uppercase;
}
.em-row__none { margin: 0; }
@media (min-width: 720px) {
  .em-row { grid-template-columns: 8.5rem minmax(0, 1fr); align-items: start; column-gap: var(--s4); }
  .em-label { padding-top: var(--s2); }
}

/* The attachments as chips: the chip opens the file, its arrow opens its menu. */
.em-attchips, .em-fchips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); min-width: 0; }
.em-attc { display: grid; gap: 2px; max-width: 100%; min-width: 0; }
.em-attc__b {
  display: inline-flex; align-items: stretch; max-width: 100%; min-width: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
}
.em-attc__open {
  display: inline-flex; align-items: center; gap: var(--s2); min-width: 0; min-height: var(--control-h-sm); padding: 0 var(--s3);
  border: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); background: transparent; color: inherit; font: inherit; text-align: left;
}
button.em-attc__open:hover { background: var(--tint); }
.em-attc__i { display: inline-grid; color: var(--ink-soft); }
.em-attc__n { min-width: 0; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.em-attc__z { color: var(--ink-mute); font-size: var(--fs-sm); white-space: nowrap; }
.em-attc__ok { display: inline-grid; color: var(--success); }
.em-attc__menu {
  display: inline-grid; place-items: center; width: var(--control-h-sm);
  border: 0; border-left: 1px solid var(--line); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: transparent; color: var(--ink-soft);
}
.em-attc__menu:hover { background: var(--tint); color: var(--ink); }
.em-attc.is-off .em-attc__open { color: var(--ink-mute); }
.em-attc__state { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s1); color: var(--ink-soft); font-size: var(--fs-sm); }
@media (pointer: coarse) {
  .em-attc__open { min-height: var(--tap); }
  .em-attc__menu { width: var(--tap); }
}

/* Filed under as chips: the kind, the name as a link, the step, the cross. */
.em-fchip {
  display: inline-flex; align-items: stretch; max-width: 100%; min-width: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--sunken);
}
.em-fchip__a {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; align-content: center; gap: 0 var(--s2); min-width: 0;
  min-height: var(--control-h-sm); padding: var(--s1) var(--s3); border-radius: var(--r-pill); color: var(--ink); text-decoration: none;
}
.em-fchip__a:hover { background: var(--tint-2); }
.em-fchip__a:hover .em-fchip__n { text-decoration: underline; text-underline-offset: 2px; }
.em-fchip__k { color: var(--ink-soft); font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--track-label); text-transform: uppercase; }
.em-fchip__c { font-weight: 600; }
.em-fchip__n, .em-fchip__s { overflow-wrap: anywhere; }
.em-fchip__s { color: var(--ink-soft); font-size: var(--fs-sm); }
.em-fchip__x {
  display: inline-grid; place-items: center; width: var(--control-h-sm);
  border: 0; border-left: 1px solid var(--line-strong); border-radius: 0 var(--r-pill) var(--r-pill) 0; background: transparent; color: var(--ink-soft);
}
.em-fchip__x:hover { background: var(--tint-2); color: var(--ink); }
@media (pointer: coarse) {
  .em-fchip__a { min-height: var(--tap); }
  .em-fchip__x { width: var(--tap); }
}
.em-links .em-dismissed { margin: var(--s2) 0 0; }

.em-bodybox { display: grid; gap: var(--s3); min-width: 0; }
.em-bodybox > p { margin: 0; }
.em-imgbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); }
.em-imgbar__b { flex: 0 1 auto; }
/* No pictures from the internet (5 Nov 2026): no note, only Open full size on the right. */
.em-imgbar--plain { justify-content: flex-end; }
.em-frame { border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
/* The frame cannot be measured from outside (it is sandboxed: no scripts, an origin of its own). Since
   27 Oct 2026 the page sets its height from the email's text and pictures (core/email-read.js,
   frameHeight()), so it grows with the email; this height is only the start, and a longer email
   scrolls inside the frame. */
.em-body { display: block; width: 100%; height: max(420px, calc(100vh - 240px)); border: 0; background: var(--surface); }
.em-fullbody { display: flex; flex: 1; min-height: 0; background: var(--surface); }
.em-body--full { flex: 1; height: auto; min-height: 0; }
.em-text { line-height: var(--lh-body); overflow-wrap: anywhere; }

.em-attlist, .em-convlist { list-style: none; margin: 0; padding: 0; display: grid; }

.em-att { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2) var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.em-att:first-child { border-top: 0; padding-top: 0; }
.em-att:last-child { padding-bottom: 0; }
.em-att__i { color: var(--ink-soft); padding-top: 2px; }
.em-att__t { display: grid; gap: 2px; min-width: 0; }
.em-att__n { font-weight: 600; overflow-wrap: anywhere; }
.em-att__s { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); font-size: var(--fs-sm); color: var(--ink-soft); }
.em-att__b { grid-column: 1 / -1; }
.em-att__saved { display: inline-flex; align-items: center; gap: var(--s1); font-weight: 600; }
@media (pointer: coarse) { .em-att__saved { min-height: var(--tap); } }

.em-conv__i { border-top: 1px solid var(--line); }
.em-conv__i:first-child { border-top: 0; }
.em-conv__a { display: grid; gap: 2px; min-height: var(--tap); padding: var(--s2) var(--s2); color: inherit; text-decoration: none; border-radius: var(--r-sm); }
a.em-conv__a:hover { background: var(--tint); }
.em-conv__i.is-here .em-conv__a { background: var(--sunken); box-shadow: inset 3px 0 0 var(--red-ink); padding-left: var(--s3); }
.em-conv__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); min-width: 0; }
.em-conv__who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.em-conv__here { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft); }
.em-conv__s {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font-size: var(--fs-sm); line-height: var(--lh-snug); overflow-wrap: anywhere;
}

.em-save { min-width: 0; }
.em-save__f { display: flex; align-items: flex-start; gap: var(--s2); margin: 0 0 var(--s4); font-weight: 600; overflow-wrap: anywhere; }
.em-save__f > span { min-width: 0; }

/* Save all (5 Nov 2026): the button beside the chips, and in its window the list of files and what was left out. */
.em-atts__body { display: grid; gap: var(--s2); justify-items: start; min-width: 0; }
.em-saveall { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.em-save__files { margin: 0 0 var(--s4); }
.em-save__files > p { margin: var(--s2) 0 0; }
.em-save__lead { margin: 0 0 var(--s2); }
.em-save__h { margin: var(--s3) 0 var(--s2); font-size: var(--fs-lg); }
.em-save__list {
  list-style: none; margin: 0; padding: 0; display: grid; max-height: 16rem; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.em-save__i { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3); border-top: 1px solid var(--line); color: var(--ink-soft); }
.em-save__i:first-child { border-top: 0; }
.em-save__t { display: grid; gap: 2px; min-width: 0; }
.em-save__n { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.em-save__why { font-size: var(--fs-sm); }

/* Long conversations (5 Nov 2026): "Show the earlier emails" under the email's own new part, outside the frame. */
.em-foldbar { display: flex; }
.em-text .em-foldbar { margin-top: var(--s3); }
.em-fold { color: var(--ink-soft); }

/* Print (27 Oct 2026): the email only. The shell is hidden by shell.css; here the way back, the bar of
   actions, the menus and crosses, the conversation and the History panel go, and the band prints in ink
   on paper. The body prints at the height of its frame. */
@media print {
  .em-imgbar, .em-acts, .em-att__b, .em-foldbar, .em-saveall { display: none; }
  .em-top, .em-bar, .em-attc__menu, .em-fchip__x, .em-pchip--more, .em-conv, .em-history { display: none !important; }
  .em-page { display: block; }
  .em-page > * + * { margin-top: var(--s3); }
  .em-band { padding: 0 0 var(--s3); border-bottom: 1px solid var(--line-strong); border-radius: 0; background: none; color: var(--ink); }
  .em-band__subject, .em-band__addr { color: var(--ink); }
  .em-band__when, .em-band__row > dt { color: var(--ink-soft); }
  .em-pchip { border-color: var(--line-strong); background: none; color: var(--ink); }
  .em-frame { border: 0; }
}

/* Inbox (items 122, 123 and 137, 21 Oct 2026): All or Unread only, Mark all as
   read, and an unread email in bold. */
.em-inbox-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); margin: var(--s3) 0; }
.em-list-note { margin: var(--s3) 0; }

/* 26 Oct 2026 (Jose: "the read and unread mails look identical"). Unread on
   Inbox, Unlinked and Deleted: the sender and the subject in bold, a blue dot
   before the sender, and a light blue tint on the row. Read mail is in normal
   weight. A ticked row keeps the red wash of a choice. */
.em-subj.is-unread .em-subj__t { font-weight: 700; color: var(--ink); }
.em-who { display: inline-flex; align-items: baseline; gap: var(--s2); min-width: 0; font-weight: 400; }
.em-who__t { min-width: 0; overflow-wrap: anywhere; }
.em-who.is-unread { font-weight: 700; color: var(--ink); }
.em-dot { flex: none; align-self: center; width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--info); }
.em-list tr:has(.em-subj.is-unread) > td { background: var(--info-bg); }
.em-list tr.is-link:has(.em-subj.is-unread):hover > td { background: linear-gradient(var(--tint), var(--tint)), var(--info-bg); }
.em-list tr.is-on:has(.em-subj.is-unread) > td { background: var(--red-wash); }
@media (max-width: 719px) {
  .em-list .tbl--collapse td.em-c-who { font-weight: 400; }
  .em-list .tbl--collapse tr:has(.em-subj.is-unread) { background: var(--info-bg); }
  .em-list .tbl--collapse tr:has(.em-subj.is-unread) > td { background: transparent; }
  .em-list .tbl--collapse.tbl--pick tr.is-on:has(.em-subj.is-unread) { background: var(--red-wash); }
}
@media (forced-colors: active) {
  .em-dot { background: CanvasText; }
}

/* 22 Oct 2026: the Outbox (who sent it). Since 26 Oct 2026 it holds only what waits for its copy in the Sent folder. */
@media (max-width: 719px) {
  .em-list .tbl--collapse td.em-c-by { grid-column: 1 / -1; grid-row: 4; font-size: var(--fs-sm); color: var(--ink-mute); }
}
@media (min-width: 720px) {
  .em-list .em-c-by { width: 1%; white-space: nowrap; }
}

/* 27 Oct 2026: an important email carries a small red "!" on the lists, the
   trails (linking.css places it) and the email page. The word Important is
   its tooltip and is read out by a screen reader. */
.em-imp {
  display: inline-grid; place-items: center; flex: none;
  width: 1.25em; height: 1.25em; margin-right: var(--s2); border-radius: var(--r-pill);
  background: var(--red); color: var(--on-red); font-size: .8em; font-weight: 700; line-height: 1; vertical-align: .1em;
}
.em-band__subject .em-imp { font-size: .6em; vertical-align: .3em; }
@media (forced-colors: active) {
  .em-imp { border: 1px solid CanvasText; }
}

/* Deleted (27 Oct 2026): its line, and Mark all as read beside it. */
.em-inbox-tools > .em-list-note { flex: 1 1 320px; margin: 0; }

/* 27 Oct 2026, Delete works with Outlook: under a row of Deleted, who or what
   deleted it, and a warning when its move to Deleted Items in Outlook
   failed. On the email page the same under the bar of actions. */
.em-subj__d { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); font-size: var(--fs-sm); color: var(--ink-mute); }
.em-subj__dw { display: inline-flex; align-items: center; gap: var(--s1); color: var(--warning-ink); font-weight: 600; }
.em-delstate { display: grid; gap: var(--s1); }
.em-delstate[hidden] { display: none; }
.em-delstate__l { display: flex; align-items: center; gap: var(--s2); margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.em-delstate__l.is-warn {
  padding: var(--s2) var(--s3); border: 1px solid var(--warning-line); border-radius: var(--r-sm);
  background: var(--warning-bg); color: var(--warning-ink); font-weight: 600;
}

/* Send/receive (27 Oct 2026) beside New email: the two arrows turn while the
   mailbox is checked. On a phone the icon alone, named by its aria-label.
   "Last checked 17:08" stands quietly under the lists. */
.em-sync.is-spinning svg { animation: llSpin 1s linear infinite; }
.em-checked { margin: var(--s2) 0 0; }
@media (max-width: 719px) {
  .em-sync { min-width: var(--tap); padding: 0 var(--s3); justify-content: center; }
  .em-sync__t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .em-sync.is-spinning svg { animation: none; }
  .em-sync.is-spinning { opacity: .6; }
}

/* Drafts (5 Nov 2026, views/emails.js): the person's own drafts. The To cell
   is the button that opens the draft (the whole row does the same); "Reply:"
   or "Forward:" stands quietly before the subject. */
.em-draft__open {
  display: block; width: 100%; min-height: var(--tap); padding: var(--s1) 0;
  color: var(--ink); font-weight: 600; text-decoration: none; text-align: left; overflow-wrap: anywhere;
}
.em-draft__open:hover .em-who__t { text-decoration: underline; text-underline-offset: 2px; }
.em-list--drafts tbody tr { cursor: pointer; }
.em-draft__mode { color: var(--ink-mute); font-weight: 400; }

/* The flag of a row (5 Nov 2026, decision 418): an outline until flagged, then filled red.
   On a phone it sits on the first line of the card, before the date. */
.em-flag {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-mute); cursor: pointer;
}
.em-flag:hover { color: var(--ink); background: var(--sunken); }
.em-flag.is-on { color: var(--red-ink); }
.em-flag.is-on svg path { fill: currentColor; }
@media (pointer: coarse) { .em-flag { width: var(--tap); height: var(--tap); } }
@media (min-width: 720px) { .em-list .em-c-flag { width: 1%; text-align: center; } }
.seg__b .i { vertical-align: -2px; margin-right: 4px; }
@media (max-width: 719px) {
  .em-list .tbl--collapse tr:has(td.em-c-flag) { grid-template-columns: minmax(0, 1fr) auto auto auto; }
  .em-list .tbl--collapse td.em-c-flag { grid-column: 3; grid-row: 1; align-self: center; padding: 0; }
  .em-list .tbl--collapse tr:has(td.em-c-flag) td.em-c-date { grid-column: 4; }
  /* The tick box sits at the top right of a card: the date stands clear of it. */
  .em-list .tbl--collapse.tbl--pick td.em-c-date { padding-right: calc(var(--tap) + var(--s1)); }

  /* The bar of ticked emails on a phone (5 Nov 2026, late): the number and Clear on the first line,
     then the buttons two by two (up to seven of them since Link came on 12 Nov 2026, decision 472), the last
     one alone across when they are odd.
     Before, every button took one column of a single row and the number stood one letter a line. */
  .em-bulk .co-bulk__dock .co-bulk__n { grid-column: 1; grid-row: 1; }
  .em-bulk .co-bulk__dock .co-bulk__clear { grid-column: 2; grid-row: 1; justify-self: end; }
  .em-bulk .co-bulk__dock .co-bulk__acts .btn { grid-row: auto; grid-column: auto; min-width: 0; white-space: normal; }
  .em-bulk .co-bulk__dock .co-bulk__acts .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* Room under the last card, so the dock never covers it. */
  .em-list:has(.em-bulk.is-on) { padding-bottom: 320px; }
}
/* The Flag button of the email page when the email is flagged (5 Nov 2026). */
.em-flagbtn.is-on .i { color: var(--red-ink); }
.em-flagbtn.is-on .i path { fill: currentColor; }
/* Where an email is filed, under its first line on the lists of incoming mail (9 Nov 2026, decision 427). */
.em-subj > .em-chips { margin-top: var(--s1); }
.em-subj > .em-chips .em-chip { max-width: min(100%, 44ch); overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* 9 Nov 2026: the order of a list, a select beside its search box on every
   screen size (views/emails.js). The Date heading is the table's own button. */
.tbl-tools__sel.em-sort { flex: 0 1 190px; }

/* 9 Nov 2026 (Jose: "As jy reply het wys hy 'n R of forward wys hy F"): a
   small R or F before the subject of an email answered or forwarded from the
   practice; who and when are its tooltip and are read out by a screen reader.
   On the email page the letter and its words, under the subject on the band.
   Never colour alone: the letter says it. */
.em-ans { display: inline-flex; gap: 2px; margin-right: var(--s2); vertical-align: .1em; }
.em-ans__m {
  display: inline-grid; place-items: center; flex: none;
  min-width: 1.4em; height: 1.4em; padding: 0 3px; border-radius: var(--r-sm);
  font-size: .75em; font-weight: 700; line-height: 1;
}
.em-ans__m--replied { background: var(--success-bg); color: var(--success-ink); }
.em-ans__m--forwarded { background: var(--info-bg); color: var(--info-ink); }
.em-band__ans { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); margin: 0; min-width: 0; }
.em-ans__m--words {
  display: inline-flex; align-items: center; gap: var(--s2); height: auto; max-width: 100%;
  padding: 2px var(--s3) 2px 2px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 600; line-height: var(--lh-snug); overflow-wrap: anywhere;
}
.em-ans__l {
  display: inline-grid; place-items: center; flex: none;
  width: 1.6em; height: 1.6em; border-radius: var(--r-pill); font-weight: 700; line-height: 1;
}
.em-ans__m--replied .em-ans__l { background: var(--success-ink); color: var(--success-bg); }
.em-ans__m--forwarded .em-ans__l { background: var(--info-ink); color: var(--info-bg); }
@media (forced-colors: active) {
  .em-ans__m, .em-ans__l { border: 1px solid CanvasText; }
}

/* ==========================================================================
   Night mode (decision 494, Jose: "The whole HUB must have a night mode").
   The email screens had a dark mode of their own (decision 466, the class
   .em-dark and a button on these pages). It is the Hub's night mode now:
   one switch beside the bell, the class is-dark on <html>, and the night
   values of the tokens in tokens.css. What is left here is what only the
   email screens need.

   The band of an email is coal by day. At night the page is as dark as the
   band, so the band becomes a card: a step up from the page, with a line.

   The body of an HTML email is its own document in a frame: the page asks
   the server for it dark (?dark=1, email_dark_css() in app/lib/emails.php),
   where white becomes the colour of a card.

   Screen only: an email prints as ink on paper, as before.
   ========================================================================== */
@media screen {
  html.is-dark .em-band {
    --chrome-bg: var(--surface);  --chrome-bg-2: var(--sunken);  --chrome-line: var(--line-strong);
    border: 1px solid var(--line);
  }
}
