/* ============================================================
   Blackbox Command Center, emails.css
   Emails screen (js/emails.js). Built on the Docs shell in css/docs.css
   (.docs-shell / .docs-side / .docs-list / .docs-row / .docs-main), so only
   the third column and the message cards are new here. Existing tokens only
   (css/main.css :root and its dark block), so both themes come for free.
   ============================================================ */

/* ============ Shell: mailboxes | threads | reading pane ============ */
.emails-shell {
  grid-template-columns: 200px 300px minmax(0, 1fr);
  gap: 26px;
}
.emails-banner { margin-bottom: 16px; }
.emails-banner[hidden] { display: none; }

.emails-mailboxes { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; }
.emails-group-label { margin-top: 10px; }
.emails-group-label:first-child { margin-top: 0; }
.emails-mb-list { overflow: visible; }
.emails-mb-main { flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px; }
.emails-mb-name { flex: 1; min-width: 0; font-weight: 500; }
.emails-mb-row.active .emails-mb-name { font-weight: 600; }
.emails-count {
  flex-shrink: 0;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

/* Thread column: sticky with its own scroll, like the Docs list. */
.emails-list-col {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 48px);
  min-width: 0;
}
.emails-list-col .docs-list-label { margin-top: 6px; min-height: 13px; }
.emails-list-col .docs-search-wrap .task-search { width: 100%; min-width: 0; }

.emails-thread-main { gap: 2px; }
.emails-thread-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.emails-thread-from { flex: 1; min-width: 0; font-weight: 500; }
.emails-thread.is-unread .emails-thread-from { font-weight: 700; }
.emails-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); flex-shrink: 0; }
.emails-thread-count { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.emails-when { font-size: 11.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; margin-left: auto; }
.emails-thread-subject {
  font-size: 12.5px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.emails-thread.is-unread .emails-thread-subject { color: var(--ink); font-weight: 600; }
.emails-thread-snippet { -webkit-line-clamp: 1; }
.emails-more-wrap { padding: 8px 4px 4px; }
.emails-more { width: 100%; }

/* ============ Reading pane ============ */
.emails-main { min-width: 0; }
.emails-placeholder { margin-top: 48px; }
.emails-topline { flex-wrap: wrap; }
.emails-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.emails-subject {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin: 2px 0 18px;
  overflow-wrap: anywhere;
}
.emails-msgs { display: flex; flex-direction: column; gap: 10px; }
.emails-msg {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  min-width: 0;
}
.emails-msg-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.emails-msg-head:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.emails-msg:not(.is-open) .emails-msg-head:hover { background: var(--hover-bg); }
.emails-msg-line { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.emails-msg-from { font-size: 13.5px; font-weight: 600; }
.emails-msg-addr { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.emails-msg-meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.emails-msg-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emails-chip {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  line-height: 17px;
}
.emails-chip--bad { color: var(--danger); }

.emails-msg.is-hidden { padding: 12px 14px; border-style: dashed; background: transparent; }
.emails-hidden-note { font-size: 13px; color: var(--muted); }

.emails-msg-body { padding: 0 14px 14px; }
.emails-images-note {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
/* The mail sits on white paper in both themes: senders design for white. */
.emails-frame-wrap {
  height: min(680px, 72vh);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  resize: vertical;
  background: #fff;
}
.emails-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
/* Plain text follows the theme (js/emails-render.js adds a dark style for it). */
:root[data-theme="dark"] .emails-frame-wrap.is-plain,
:root[data-theme="dark"] .emails-frame-wrap.is-plain .emails-frame { background: transparent; }
.emails-msg-error { font-size: 13px; color: var(--danger); margin: 4px 0; }

.emails-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.emails-att {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.emails-att:hover { border-color: var(--btn-border-hover); background: var(--hover-bg); }
.emails-att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.emails-att-size { color: var(--muted); flex-shrink: 0; }

.emails-loading { padding-top: 6px; }
.emails-skel-body { height: 260px; margin-top: 22px; }


/* Gate states (Confirm it's you, no access, error): one message, full width. */
.emails-shell.is-gate .emails-list-col { display: none; }
.emails-shell.is-gate .emails-main { grid-column: 1 / -1; }
.emails-shell.is-gate .emails-placeholder { margin-top: 8px; }

/* ============ Narrower screens: mailboxes become a row of chips ============ */
@media (max-width: 1399px) {
  .emails-shell { grid-template-columns: 290px minmax(0, 1fr); }
  .emails-boxes { grid-column: 1 / -1; position: static; max-height: none; }
  .emails-mailboxes { flex-direction: row; flex-wrap: wrap; gap: 6px; overflow: visible; }
  .emails-group-label { display: none; }
  .emails-mb-list { display: contents; }
  .emails-mb-row { border: 1px solid var(--border); border-radius: 999px; }
  .emails-mb-row.active { border-color: transparent; }
  .emails-mb-main { padding: 5px 12px; border-radius: 999px; }
}
@media (max-width: 1100px) {
  .emails-shell { grid-template-columns: 250px minmax(0, 1fr); gap: 20px; }
}

/* Phone: one column at a time, the reading pane gets a Back button
   (.docs-back is shown under 768px by css/docs.css). */
@media (max-width: 767px) {
  .emails-boxes { margin-bottom: 14px; }
  .emails-list-col { position: static; max-height: none; }
  .emails-list-col .docs-list { overflow: visible; }
  .emails-shell.has-thread .emails-boxes,
  .emails-shell.has-thread .emails-list-col { display: none; }
  .emails-shell:not(.has-thread) .emails-main { display: none; }
  /* docs.css hides .docs-main without .has-doc; this screen uses .has-thread. */
  .docs-shell.emails-shell.has-thread .emails-main { display: block; }
  .docs-shell.emails-shell.is-gate .emails-boxes { display: flex; }
  .emails-placeholder { margin-top: 12px; }
  .emails-subject { font-size: 19px; }
  .emails-msg-body { padding: 0 10px 10px; }
  .emails-frame-wrap { height: 64vh; }
}

/* ============ Side head: Compose + Admin ============ */
/* The title never shrinks under the buttons; they wrap to their own row instead. */
.emails-boxes .docs-side-head { flex-wrap: wrap; justify-content: flex-start; row-gap: 8px; }
.emails-boxes .docs-side-head .page-title { flex: 1 0 auto; }
.emails-admin-btn { white-space: nowrap; }

/* ============ Compose panel (js/emails-compose.js) ============
   Docked bottom right on desktop so the thread stays readable beside it;
   full screen on a phone. */
.emc-panel {
  position: fixed;
  right: 24px;
  bottom: 0;
  z-index: 150;
  width: min(660px, calc(100vw - 48px));
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-lift);
  animation: td-slide-in var(--dur-slower) var(--ease);
}
.emc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.emc-title { flex: 1; margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 600; }
.emc-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 12px; display: flex; flex-direction: column; }
/* The body scrolls; its rows keep their own height instead of squeezing. */
.emc-body > * { flex-shrink: 0; }

.emc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border-bottom: 1px solid var(--border-soft);
  min-width: 0;
}
.emc-label { width: 40px; flex-shrink: 0; font-size: 12.5px; color: var(--muted); }
.emc-from { flex-wrap: wrap; row-gap: 0; padding: 6px 0; }
.emc-from-value { font-size: 13px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.emc-hint { flex-basis: 100%; padding-left: 50px; font-size: 11.5px; color: var(--faint); }

.emc-chip-box { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; padding: 5px 0; }
.emc-chips { display: contents; }
.emc-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 1px 2px 1px 9px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink);
  font-size: 12.5px;
  line-height: 22px;
}
.emc-chip.is-bad { background: var(--chip-red-bg); color: var(--danger); }
.emc-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.emc-chip-x {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.emc-chip-x:hover { color: var(--ink); background: var(--hover-bg); }
.emc-chip-input,
.emc-subject {
  flex: 1;
  min-width: 120px;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  padding: 4px 0;
}
.emc-chip-input:focus, .emc-subject:focus { outline: none; }
.emc-subject { font-weight: 500; }
.emc-link-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.emc-link-btn:hover { color: var(--ink); }

.emc-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 8px; }
.emc-fmt { min-width: 32px; }
.emc-fmt--bold { font-weight: 800; }
.emc-fmt--italic { font-style: italic; font-family: Georgia, serif; }
.emc-link-row { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 8px; }
.emc-link-url {
  flex: 1;
  min-width: 180px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  font-size: 12.5px;
}
.emc-link-url:focus { outline: none; border-color: var(--input-focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }

.emc-editor {
  min-height: 160px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  cursor: text;
}
.emc-editor:focus, .emc-editor:focus-within { outline: none; border-color: var(--input-focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.emc-editor blockquote { margin: 6px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--ink-soft); }
.emc-editor ul, .emc-editor ol { margin: 4px 0; padding-left: 22px; }
.emc-editor a { color: var(--ink); text-decoration: underline; }
.emc-plain { width: 100%; min-height: 150px; border: none; background: transparent; color: inherit; font: inherit; resize: vertical; }
.emc-plain:focus { outline: none; }

.emc-quote { margin-top: 12px; }
.emc-quote-label { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.emc-quote-wrap {
  height: 150px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  resize: vertical;
  background: #fff;
}
.emc-quote-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

.emc-zone { margin-top: 12px; }
.emc-files { display: flex; flex-wrap: wrap; gap: 6px; }
.emc-files:not(:empty) { margin-bottom: 8px; }
.emc-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 4px 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 12.5px;
}
.emc-file.is-bad { border-color: var(--danger); color: var(--danger); }
.emc-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.emc-file-size { color: var(--muted); flex-shrink: 0; }
.emc-file.is-bad .emc-file-size { color: var(--danger); }

.emc-meter { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.emc-meter-track { flex: 0 0 120px; height: 5px; border-radius: 999px; background: var(--chip-bg); overflow: hidden; }
.emc-meter-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ink-soft); transition: width var(--dur) var(--ease); }
.emc-meter.is-over, .emc-meter.is-warn { color: var(--danger); font-weight: 600; }
.emc-meter.is-over .emc-meter-fill { background: var(--danger); }

.emc-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.emc-note--bad { color: var(--danger); }

.emc-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border-soft);
}
.emc-status { flex: 1; min-width: 0; margin: 0; font-size: 12.5px; color: var(--danger); }
.emc-foot-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.emc-send[disabled] { opacity: 0.45; cursor: not-allowed; }
.emc-confirm { flex: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }

@media (max-width: 767px) {
  .emc-panel {
    inset: 0;
    width: 100vw;
    max-height: none;
    border: none;
    border-radius: 0;
  }
  .emc-body { padding: 4px 16px 12px; }
  .emc-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
  .emc-editor { max-height: none; }
  .emc-hint { padding-left: 0; }
}

/* ============ Admin drawer (js/emails-admin.js) ============
   Geometry from .cm-drawer in main.css; only the body is new. */
.ema-body { gap: 0; }
.ema-muted { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.ema-error { margin: 6px 0; font-size: 12.5px; color: var(--danger); }
.ema-switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.ema-switch-row.is-on { border-color: var(--danger); }
.ema-switch-text { flex: 1; min-width: 0; }
.ema-switch-label { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.ema-switch-wrap .ema-switch-row { margin-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ema-confirm {
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--chip-red-bg);
  font-size: 13px;
  color: var(--ink);
}
.ema-confirm p { margin: 0 0 10px; line-height: 1.5; }
.ema-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.ema-mailboxes { display: flex; flex-direction: column; gap: 8px; }
.ema-mb {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ema-mb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ema-mb-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; font-weight: 600; }
.ema-add { padding-top: 2px; }

.ema-people { display: flex; flex-direction: column; gap: 8px; }
.ema-person { flex-wrap: wrap; }
.ema-person-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ema-person .ema-mb-main { overflow-wrap: anywhere; }

.ema-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--input-focus-border);
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
}
.ema-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ema-field-label { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.ema-hint { font-size: 11.5px; color: var(--faint); }
.ema-input {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.ema-input:focus { outline: none; border-color: var(--input-focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.ema-owners { resize: vertical; font-family: var(--mono); font-size: 12px; }
.ema-address { display: flex; align-items: flex-end; gap: 6px; }
.ema-address .ema-field { flex: 1; }
.ema-at { padding-bottom: 8px; color: var(--muted); }
.ema-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); white-space: nowrap; }
.ema-check { width: 15px; height: 15px; accent-color: var(--ink); }

.ema-audit { display: flex; flex-direction: column; }
.ema-log { padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.ema-log-top { display: flex; align-items: baseline; gap: 8px; }
.ema-log-what { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; }
.ema-log-detail { font-family: var(--mono); font-size: 11.5px; margin-top: 2px; }
.ema-more { margin-top: 10px; align-self: flex-start; }

/* ============ "Forward to" setting (js/emails-forward.js) ============
   A small dots button next to the mailbox name opens a one-item menu; the menu
   opens a right-side drawer (geometry from .cm-drawer in main.css). Existing
   tokens only, so both themes work. */
.emf-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.emf-head .docs-list-label { flex: 1; min-width: 0; }
.emf-wrap { position: relative; flex-shrink: 0; }
.emf-wrap[hidden] { display: none; }
.emf-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 26px;
  height: 22px;
  padding: 0;
  margin-top: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.emf-more:hover, .emf-more[aria-expanded="true"] { background: var(--hover-bg); color: var(--ink); }
.emf-more:focus-visible { outline: none; border-color: var(--input-focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.emf-dot { width: 3.5px; height: 3.5px; border-radius: 50%; background: currentColor; }
.emf-menu {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  z-index: 60;
  min-width: 140px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-lift);
}
.emf-menuitem {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.emf-menuitem:hover, .emf-menuitem:focus-visible { background: var(--hover-bg); outline: none; }
.emf-sub { margin: -4px 2px 0; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.emf-sub[hidden] { display: none; }
.emf-body { gap: 10px; }
@media (min-width: 641px) { .emf-panel { width: min(420px, 100vw); } }
.emf-label { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.emf-form { display: flex; align-items: center; gap: 6px; min-width: 0; }
.emf-input {
  flex: 1;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.emf-input:focus { outline: none; border-color: var(--input-focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.emf-input:disabled { opacity: 0.6; }
.emf-save { flex-shrink: 0; }
.emf-statusrow { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.emf-status { margin: 0; font-size: 12.5px; color: var(--ink); overflow-wrap: anywhere; }
.emf-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.emf-confirm { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--hover-bg); }
.emf-confirm-text { margin: 0; font-size: 12.5px; color: var(--ink); overflow-wrap: anywhere; }
.emf-confirm-actions { display: flex; gap: 6px; }
.emf-error { margin: 0; font-size: 12px; color: var(--danger); overflow-wrap: anywhere; }
.emf-last { margin: 0; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.emf-note { margin: 0; font-size: 11.5px; color: var(--faint); }

/* ============ Folders, bulk actions, row actions (js/emails.js, 2026-10-30) ============
   The tabs and the bulk bar are the first children of #emails-threads and stick to its top
   while the rows scroll. Existing tokens only, so both themes work. */
.emails-toolbar { position: sticky; top: 0; z-index: 3; margin: 0 -6px; padding: 2px 6px 0; background: var(--page); }
.emails-folders {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.emails-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 4px 9px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.emails-tab:hover { background: var(--hover-bg); color: var(--ink); }
.emails-tab:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.emails-tab.active { background: var(--tint-active); color: var(--tint-active-ink); font-weight: 600; }
.emails-tab-count { min-width: 16px; line-height: 16px; font-size: 10.5px; padding: 0 5px; }

.emails-bulk:empty { display: none; }
.emails-bulk-row { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 4px; flex-wrap: wrap; }
.emails-bulk-row.has-selection { border-bottom: 1px solid var(--border-soft); }
.emails-bulk-note { font-size: 12px; color: var(--muted); flex: 1; min-width: 0; }
.emails-bulk-count { font-size: 12px; font-weight: 600; color: var(--ink); }
.emails-bulk-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.emails-bulk-btn { padding: 3px 8px; font-size: 12px; }
.emails-empty-trash { margin-left: auto; }

.emails-check-wrap { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; cursor: pointer; }
.emails-check { width: 15px; height: 15px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.emails-check:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.emails-rows { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.emails-thread { position: relative; }
.emails-thread .emails-check-wrap { margin-left: 2px; }
.emails-thread.is-selected { background: var(--tint-active); }
.emails-star { color: var(--ink); font-size: 12px; flex-shrink: 0; line-height: 1; }

.emails-row-actions {
  position: absolute;
  top: 5px;
  right: 6px;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-lift);
}
.emails-thread:hover .emails-row-actions,
.emails-thread:focus-within .emails-row-actions { display: flex; }
.emails-act {
  padding: 2px 7px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.emails-act:hover, .emails-act:focus-visible { background: var(--hover-bg); outline: none; }
.emails-act.is-danger { color: var(--danger); }
/* No hover on touch screens: the open thread's toolbar and the checkboxes cover everything. */
@media (hover: none) { .emails-row-actions { display: none !important; } }

.emails-tactions { margin-right: 6px; }
.emails-draft-note { margin: 10px 4px 4px; font-size: 11.5px; color: var(--faint); }

/* ============ Confirm dialog and shortcuts sheet (js/emails.js) ============ */
.emx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 18, 26, 0.4);
}
.emx-dialog {
  width: min(380px, 100%);
  padding: 18px 20px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
}
.emx-dialog-title { margin: 0 0 6px; font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.emx-dialog-body { margin: 0 0 14px; font-size: 13px; line-height: 1.5; color: var(--ink-soft); }
.emx-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.emx-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 10px 0 14px; }
.emx-key-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.emx-key {
  min-width: 24px;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--hover-bg);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}
.emx-key-label { font-size: 12.5px; color: var(--ink-soft); min-width: 0; }
@media (max-width: 480px) { .emx-keys { grid-template-columns: 1fr; } }

/* ============ Draft state in the compose footer, signature box ============ */
.emc-draftstate { flex-shrink: 0; font-size: 11.5px; color: var(--muted); }
.emc-files-note { display: block; }
.emf-sig { width: 100%; resize: vertical; min-height: 110px; line-height: 1.5; font-family: inherit; }
