/* Compose window (mailCompose.js openCompose). Sits above the document overlays (z 3000). */
/* The main app's style.css sets bare label/input/button/* rules (label margin 2em, bold
   1.25em, Arial everywhere, button margin 5px), so this window resets what it uses. */
.mc-card, .mc-card * { font-family: var(--font-body, 'Public Sans', system-ui, sans-serif); box-sizing: border-box; }
.mc-card label { margin: 0; font-size: 14px; font-weight: 400; color: inherit; }
.mc-card button { margin: 0; }
.mc-card input, .mc-card textarea, .mc-card select { margin: 0; }
.mc-card [hidden] { display: none !important; }
.mc-card .mc-mono, .mc-card .mc-mono * { font-family: var(--font-mono, 'Spline Sans Mono', ui-monospace, monospace); }

.mc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(12, 44, 73, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.mc-card {
  position: relative;
  width: min(1080px, 100%);
  height: min(700px, calc(100vh - 32px));
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(8, 24, 40, .35);
  font: 14px/1.45 var(--font-body, 'Public Sans', system-ui, sans-serif);
  color: #102A43;
}

/* ----- template sidebar ----- */
.mc-side {
  background: #F4F7FA;
  border-right: 1px solid #E4EAF0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 14px 14px;
  gap: 10px;
}
.mc-card .mc-side-title { font: 800 15px var(--font-display, 'Archivo', system-ui, sans-serif); padding: 0 4px; }
.mc-card .mc-side-search {
  height: 36px;
  border: 1px solid #E4EAF0;
  border-radius: 9px;
  padding: 0 12px;
  font-size: 13.5px;
  background: #fff;
  color: #102A43;
  width: 100%;
}
.mc-side-search::placeholder { color: #8A9AAB; }
.mc-side-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.mc-side-group { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: #6E8398; padding: 12px 6px 4px; }
.mc-trow {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}
.mc-trow:hover { background: rgba(255, 255, 255, .7); }
.mc-trow.on { background: #fff; border-color: #BCD3EC; }
.mc-trow:focus-visible { outline: 2px solid #1462B8; outline-offset: 1px; }
.mc-card .mc-tname { font-weight: 600; font-size: 13.5px; color: #102A43; padding-right: 18px; }
.mc-card .mc-tnote { font-weight: 500; font-size: 12px; color: #62748A; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-draft-x { position: absolute; top: 6px; right: 4px; }
.mc-side-empty { padding: 10px 6px; font-size: 13px; }
.mc-side-foot { font-size: 12.5px; font-weight: 600; color: #1462B8; text-decoration: none; padding: 4px; }
.mc-side-foot:hover { text-decoration: underline; }

/* ----- main column ----- */
.mc-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mc-head {
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 22px;
  border-bottom: 1px solid #EEF2F6;
}
.mc-card .mc-title { font: 800 17px var(--font-display, 'Archivo', system-ui, sans-serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mc-context { padding: 3px 9px; border-radius: 999px; background: #EEF2F6; font-size: 12px; font-weight: 600; color: #4A5D70; white-space: nowrap; }
.mc-seg { margin-left: auto; display: flex; padding: 3px; border-radius: 10px; background: #EEF2F6; flex-shrink: 0; }
.mc-card .mc-seg button {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #62748A;
  cursor: pointer;
}
.mc-card .mc-seg button[aria-selected="true"] { background: #fff; color: #102A43; box-shadow: 0 1px 2px rgba(16, 42, 67, .12); }
.mc-x { border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: #62748A; padding: 0 6px; }
.mc-side-toggle { display: none; border: none; background: none; font-size: 18px; color: #3D4F60; cursor: pointer; padding: 0 4px; }

.mc-replace {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  background: #FDF1DC;
  color: #8A5A00;
  font-size: 13.5px;
}
.mc-replace span { flex: 1; }

.mc-write { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 22px; }
.mc-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 0;
  border-bottom: 1px solid #EEF2F6;
  font-size: 13.5px;
}
.mc-card .mc-label { width: 56px; flex-shrink: 0; font-weight: 600; font-size: 13px; color: #62748A; }
.mc-from { flex-wrap: wrap; row-gap: 2px; }
.mc-card .mc-from .mc-mono { font-size: 12.5px; }
.mc-from-reply { margin-left: auto; font-size: 12.5px; }
.mc-muted { color: #62748A; font-weight: 400; }
.mc-warn { color: #8A5A00; font-weight: 600; }

.mc-chips { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; cursor: text; }
.mc-card .mc-addr {
  flex: 1;
  min-width: 140px;
  height: 30px;
  border: none;
  outline: none;
  font-size: 14px;
  color: #102A43;
  background: transparent;
  padding: 0;
}
.mc-addr::placeholder { color: #8A9AAB; }
.mc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 4px 3px 4px;
  border-radius: 999px;
  background: #EEF2F6;
  font-size: 13px;
}
.mc-person-name { font-weight: 600; white-space: nowrap; }
.mc-card .mc-person .mc-mono { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1462B8;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
}
.mc-chip-x { border: none; background: none; color: #62748A; font-size: 17px; line-height: 1; cursor: pointer; padding: 0 4px; }
.mc-chip-x:hover { color: #102A43; }
.mc-link { border: none; background: none; color: #1462B8; font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px; }

.mc-lookup {
  position: absolute;
  z-index: 3;
  top: calc(100% - 2px);
  left: 66px;
  right: 0;
  max-width: 520px;
  background: #fff;
  border: 1px solid #E4EAF0;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(16, 42, 67, .1);
  padding: 6px;
}
.mc-look { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.mc-look.on, .mc-look:hover { background: #F0F6FC; }
.mc-look .mc-av { width: 30px; height: 30px; font-size: 11.5px; }
.mc-look-text { display: flex; flex-direction: column; min-width: 0; }
.mc-look-text b { font-size: 13.5px; font-weight: 600; }
.mc-look-text .mc-muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- editors: text over a backdrop that shows {fields} as chips (same metrics) ----- */
.mc-ed { position: relative; flex: 1; min-width: 0; }
.mc-ed-hl, .mc-card .mc-ed-in {
  font: 400 14.5px/1.65 var(--font-body, 'Public Sans', system-ui, sans-serif);
  letter-spacing: normal;
  word-spacing: normal;
  padding: 14px 0;
  border: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
}
.mc-ed-hl { position: absolute; inset: 0; overflow: hidden; color: #1D2733; pointer-events: none; }
.mc-card .mc-ed-in {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  resize: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: #102A43;
}
.mc-ed-in::selection { background: rgba(20, 98, 184, .22); color: transparent; }
.mc-ed-line { height: 34px; }
.mc-ed-line .mc-ed-hl, .mc-card .mc-ed-line .mc-ed-in { padding: 6px 0; white-space: pre; font-weight: 600; font-size: 14px; line-height: 22px; }
.mc-ed-body { flex: 1; min-height: 120px; }
.mc-ed-body .mc-ed-hl { overflow-y: hidden; }
.mc-card .mc-ed-body .mc-ed-in { overflow-y: auto; }
.mc-tok { background: #E3EEFA; color: #1462B8; border-radius: 4px; box-shadow: 0 0 0 2px #E3EEFA; font-weight: inherit; }
.mc-tok-btn { background: transparent; box-shadow: none; outline: 1.5px dashed #1462B8; outline-offset: 1px; }

.mc-under {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0 10px;
  border-top: 1px solid #EEF2F6;
  flex-wrap: wrap;
}
.mc-card .mc-sig { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mc-card .mc-sig select {
  height: 32px;
  border: 1px solid #D5DEE7;
  border-radius: 9px;
  padding: 0 28px 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #102A43;
  background: #fff;
}
.mc-fields-wrap { position: relative; }
.mc-fields {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 3;
  width: 320px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: #fff;
  border: 1px solid #E4EAF0;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(16, 42, 67, .1);
}
.mc-card .mc-field-chip {
  border: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: #E3EEFA;
  color: #1462B8;
  cursor: pointer;
  font: 600 12.5px var(--font-mono, 'Spline Sans Mono', ui-monospace, monospace);
}

/* ----- preview ----- */
.mc-preview { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #EEF2F6; }
.mc-preview-subj { padding: 12px 22px; background: #fff; border-bottom: 1px solid #E4EAF0; font-weight: 600; font-size: 14px; }
.mc-preview-subj .mc-muted { font-weight: 600; font-size: 12px; margin-right: 8px; }
.mc-preview-frame { flex: 1; width: 100%; border: none; background: #E9EEF3; }

.mc-error {
  margin: 0 22px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #FBEAEA;
  color: #9B2C2C;
  font-size: 13px;
  font-weight: 600;
}

/* ----- footer ----- */
.mc-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 14px 22px;
  border-top: 1px solid #EEF2F6;
  flex-wrap: wrap;
}
.mc-attach { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.mc-file { border-radius: 9px; padding: 4px 4px 4px 6px; background: #F4F7FA; border: 1px solid #E4EAF0; }
.mc-filetag { padding: 1px 5px; border-radius: 4px; background: #B23B3B; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.mc-chip-name { font-weight: 600; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-chip-wait { color: #62748A; padding: 5px 10px; }
.mc-saved { margin-left: auto; font-size: 12.5px; color: #62748A; }
.mc-btn {
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid #D5DEE7;
  background: #fff;
  color: #102A43;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.mc-btn:hover { background: #F4F7FA; }
.mc-btn-ghost { border-color: #D5DEE7; }
.mc-btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.mc-card .mc-attach-add { height: 34px; padding: 0 12px; font-size: 13px; font-weight: 700; }
.mc-primary { background: #1462B8; border-color: #1462B8; color: #fff; }
.mc-primary:hover { background: #10559F; }
.mc-btn:disabled { opacity: .55; cursor: default; }

/* ----- Undo toast ----- */
.mc-undo {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 5100;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px 12px 18px;
  border-radius: 12px;
  background: #102A43;
  color: #fff;
  font: 600 14px var(--font-body, 'Public Sans', system-ui, sans-serif);
  box-shadow: 0 10px 30px rgba(16, 42, 67, .3);
}
.mc-undo button {
  margin: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font: 700 13.5px var(--font-body, 'Public Sans', system-ui, sans-serif);
  padding: 7px 14px;
  cursor: pointer;
}
.mc-undo button:hover { background: rgba(255, 255, 255, .24); }

/* ----- phones and narrow windows: the templates slide in from the ☰ button ----- */
@media (max-width: 760px) {
  .mc-backdrop { padding: 0; }
  .mc-card { grid-template-columns: minmax(0, 1fr); height: 100%; border-radius: 0; }
  .mc-side { position: absolute; z-index: 4; inset: 0 auto 0 0; width: min(300px, 86%); transform: translateX(-100%); transition: transform .18s ease; box-shadow: 0 10px 30px rgba(16, 42, 67, .2); }
  .mc-card.mc-side-open .mc-side { transform: none; }
  .mc-side-toggle { display: inline-block; }
  .mc-head { padding: 0 8px 0 10px; gap: 8px; }
  .mc-context { display: none; }
  .mc-write { padding: 0 14px; }
  .mc-foot { padding: 10px 14px 12px; }
  .mc-from-reply { margin-left: 66px; }
  .mc-lookup { left: 0; }
}

/* ----- Emails list for a record (emailHistory.js) ----- */
.eh-backdrop { position: fixed; inset: 0; z-index: 4900; background: rgba(12, 44, 73, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.eh-card, .eh-card * { box-sizing: border-box; font-family: var(--font-body, 'Public Sans', system-ui, sans-serif); }
.eh-card button { margin: 0; }
.eh-card { width: min(1240px, 100%); height: min(760px, calc(100vh - 32px)); display: flex; flex-direction: column; background: #F4F7FA; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(8, 24, 40, .35); color: #102A43; }
.eh-head { display: flex; align-items: center; gap: 14px; padding: 20px 24px 16px 28px; background: #fff; border-bottom: 1px solid #E4EAF0; }
.eh-av { width: 44px; height: 44px; border-radius: 50%; background: #1462B8; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.eh-who { flex: 1; min-width: 0; }
.eh-card .eh-name { font: 800 21px var(--font-display, 'Archivo', system-ui, sans-serif); }
.eh-sub { font-weight: 500; font-size: 13.5px; color: #62748A; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-bar { display: flex; align-items: center; gap: 8px; padding: 18px 28px 14px; flex-wrap: wrap; }
.eh-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.eh-card .eh-pill { border: none; cursor: pointer; padding: 7px 14px; border-radius: 999px; background: #EEF2F6; color: #5A6B7B; font-weight: 700; font-size: 13.5px; }
.eh-card .eh-pill.on { background: #0C2C49; color: #fff; }
.eh-note { margin-left: auto; font-weight: 500; font-size: 13px; color: #62748A; }
.eh-list { flex: 1; min-height: 0; overflow: auto; margin: 0 28px 22px; background: #fff; border: 1px solid #E4EAF0; border-radius: 14px; }
.eh-empty { padding: 28px; color: #62748A; font-size: 14px; }
.eh-row { border-bottom: 1px solid #EEF2F6; }
.eh-row.open { background: #FAFCFE; }
.eh-card .eh-line { width: 100%; border: none; background: transparent; cursor: pointer; text-align: left; display: grid; grid-template-columns: 120px minmax(0, 1fr) 130px 140px 110px; gap: 16px; align-items: center; padding: 14px 20px; color: inherit; font-size: 14px; }
.eh-line:focus-visible { outline: 2px solid #1462B8; outline-offset: -2px; }
.eh-card .eh-when { font: 600 13px var(--font-mono, 'Spline Sans Mono', ui-monospace, monospace); color: #3D4F60; }
.eh-subj { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.eh-subj b { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-subj span { font-weight: 500; font-size: 12.5px; color: #62748A; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-type { justify-self: start; padding: 3px 9px; border-radius: 999px; background: #EEF2F6; font-weight: 600; font-size: 12px; color: #4A5D70; }
.eh-by { font-weight: 500; font-size: 13px; color: #3D4F60; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-status { justify-self: end; display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.eh-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.eh-status.ok { color: #1F8B4D; }
.eh-status.bad { color: #B23B3B; }
.eh-more { padding: 0 20px 18px 156px; display: flex; flex-direction: column; gap: 12px; }
.eh-error { padding: 10px 14px; border-radius: 10px; background: #FBEAEA; font-weight: 600; font-size: 13.5px; color: #9B2C2C; }
.eh-preview { padding: 14px 16px; border-radius: 10px; background: #F4F7FA; font-size: 14px; line-height: 1.6; color: #2C3E50; max-width: 720px; max-height: 260px; overflow: auto; }
.eh-actions, .eh-fix { display: flex; gap: 8px; flex-wrap: wrap; }
.eh-card .eh-fix input { height: 30px; border: 1px solid #D5DEE7; border-radius: 9px; padding: 0 10px; font-size: 13.5px; min-width: 260px; }
@media (max-width: 760px) {
  .eh-backdrop { padding: 0; }
  .eh-card { height: 100%; border-radius: 0; }
  .eh-head { padding: 14px 12px 12px 14px; flex-wrap: wrap; }
  .eh-bar { padding: 12px 14px 10px; }
  .eh-note { margin-left: 0; width: 100%; }
  .eh-list { margin: 0 0 0; border-radius: 0; border-left: none; border-right: none; }
  .eh-card .eh-line { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; }
  .eh-when { grid-column: 1; grid-row: 2; }
  .eh-subj { grid-column: 1; grid-row: 1; }
  .eh-type, .eh-by { display: none; }
  .eh-status { grid-column: 2; grid-row: 1 / span 2; }
  .eh-more { padding: 0 14px 14px; }
}

/* ----- Send later ----- */
.mc-later-wrap { position: relative; }
.mc-later { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 4; width: 280px; background: #fff; border: 1px solid #E4EAF0; border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 42, 67, .1); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.mc-card .mc-later > button { border: none; background: none; text-align: left; padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; color: #102A43; }
.mc-card .mc-later > button:hover { background: #F0F6FC; }
.mc-later b { font-size: 13.5px; font-weight: 600; }
.mc-later span { font-size: 12.5px; color: #62748A; }
.mc-later-pick { display: flex; flex-direction: column; gap: 6px; padding: 9px 10px 6px; border-top: 1px solid #EEF2F6; margin-top: 2px; }
.mc-card .mc-later-pick input { height: 34px; border: 1px solid #D5DEE7; border-radius: 9px; padding: 0 10px; font-size: 13.5px; color: #102A43; }
.mc-card .mc-later-pick .mc-btn { align-self: flex-start; }
.mc-card .mc-tnote-bad { color: #B23B3B; }
