/* DP Mail - compact message view (see reader-strip js). */

/* ---------- AI buttons at the end of the subject line ---------- */
.reading > h2:has(> .dpm-ai-strip) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.dpm-ai-strip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  font: 500 12.5px/1 var(--font-ui, system-ui, sans-serif);
  letter-spacing: normal;
}
.dpm-ai-strip .ai-mark { width: 22px; height: 22px; }
.dpm-ai-strip .ai-mark svg { width: 13px; height: 13px; }
.dpm-ai-strip .btn { height: 26px !important; padding: 0 9px; font-size: 12.5px; }

/* Hide the app's own AI row only while its copy is on the subject line... */
.reading:has(> h2 > .dpm-ai-strip) > .ai-assist > .ai-row { display: none; }
/* ...and the whole AI block when that row was all it showed (no empty gap). */
.reading:has(> h2 > .dpm-ai-strip) > .ai-assist:not(:has(> :not(.ai-row))) { display: none; }

/* ---------- slim "content from the internet" notice ---------- */
html.dpm-compact .reading > .trust-bar {
  padding: 3px 6px 3px 10px;
  gap: 4px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  flex-wrap: nowrap;
  flex-shrink: 0;          /* never squeezed by a long message in the scrolling pane */
}
html.dpm-compact .reading > .trust-bar > span:not(.tb-acts) {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
html.dpm-compact .reading > .trust-bar > svg { width: 15px; height: 15px; }
html.dpm-compact .reading > .trust-bar .btn { height: 26px !important; padding: 0 9px; font-size: 12.5px; }
html.dpm-compact .reading > .trust-bar .tb-acts { flex-wrap: nowrap; flex: 0 0 auto; }
@media (max-width: 720px) {
  html.dpm-compact .reading > .trust-bar { flex-wrap: wrap; }
}

/* ---------- compact attachment ribbon (html.dpm-compact is set by the js) ---------- */
html.dpm-compact .att-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
html.dpm-compact .att-head {
  flex: 0 0 auto;
  gap: 5px;
  font-size: 12.5px;
  margin-right: 2px;
}
html.dpm-compact .att-head .spacer { display: none; }
html.dpm-compact .att-head svg { width: 14px; height: 14px; }
html.dpm-compact .att-all { height: 26px; padding: 0 8px; margin-left: 4px; }
html.dpm-compact .att-card {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 340px;
  height: 30px;
  border-radius: 8px;
}
html.dpm-compact .att-main { gap: 7px; padding: 0 8px 0 6px; }
html.dpm-compact .att-main .fic {
  min-width: 20px;
  height: 22px;
  font-size: 7px;
  border-radius: 3px;
}
html.dpm-compact .att-txt { flex-direction: row; align-items: baseline; gap: 6px; min-width: 0; }
html.dpm-compact .att-name { font-size: 12.5px; max-width: 260px; }
html.dpm-compact .att-txt .muted { font-size: 11.5px; white-space: nowrap; flex: 0 0 auto; }
html.dpm-compact .att-dl { padding: 0 8px; }
html.dpm-compact .att-dl span { display: none; }   /* icon only; the button's tooltip names the file */
html.dpm-compact .att-dl svg { width: 14px; height: 14px; }

/* ---------- subject line stays put while the message scrolls ---------- */
html.dpm-compact .reading > h2 {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface);
  padding-top: 6px;
  padding-bottom: 6px;
  margin-top: -6px;           /* same place as before when not scrolled */
  box-shadow: 0 -24px 0 var(--surface);   /* covers the pane's top padding above it */
  flex-shrink: 0;
}
html.dpm-compact .reading > h2.dpm-stuck { border-bottom: 1px solid var(--line); }

/* ---------- one scrollbar ---------- */
/* hidden frame used only to measure the message's height */
iframe.dpm-measure { position: fixed; left: -10000px; top: 0; height: 1px; border: 0; visibility: hidden; pointer-events: none; }
/* the real message frame, once measured: exactly as tall as the email */
html.dpm-compact .reading iframe.html-frame.dpm-fit { min-height: 80px; display: block; overflow: hidden; }
/* the pane's scrollbar track starts under the pinned subject (Chrome, Edge, Safari) */
html.dpm-compact .reading { scrollbar-width: auto; scrollbar-color: auto; }
html.dpm-compact .reading::-webkit-scrollbar-track { margin-top: var(--dpm-subj-h, 0px); }
@supports not selector(::-webkit-scrollbar) {
  html.dpm-compact .reading { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
}

/* ---------- reply / forward editor: long quoted mail can be scrolled ---------- */
/* The app's editor box (.rte, overflow hidden) was squeezed to the pane height
   and cut off the rest of a long quoted message. It now keeps its full height
   and the reply form scrolls, with the formatting bar pinned at the top. */
html.dpm-compact .compose-inline { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
html.dpm-compact .compose-inline > * { flex-shrink: 0; }
html.dpm-compact .compose-inline .rte { flex-shrink: 0; overflow: visible; }
html.dpm-compact .compose-inline .rte-bar { position: sticky; top: -10px; z-index: 3; border-radius: 10px 10px 0 0; }

/* ---------- "Run now" for mail rules ---------- */
.dpm-run-rule { color: var(--accent); }
.dpm-run-veil { position: fixed; inset: 0; z-index: 95; background: #0a142266; display: grid; place-items: center; padding: 16px; }
.dpm-run-card { width: min(520px, 100%); background: var(--panel); color: var(--text); border-radius: 14px; box-shadow: 0 18px 50px #0f192859; padding: 18px 20px 16px; }
.dpm-run-card h3 { margin: 0 0 8px; font-size: 17px; }
.dpm-run-card p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.dpm-run-opt { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; cursor: pointer; }
.dpm-run-list { margin: 0 0 10px; padding-left: 18px; font-size: 13px; max-height: 150px; overflow: auto; }
.dpm-run-list li { margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dpm-run-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dpm-run-err { color: var(--bad-fg, #B42318); }
