/* ===== EMAIL MODULE — three-pane mail client (folders / list / reading pane) ===== */
.email__shell {
  --em-line: var(--bo-line, #e6e9ef);
  --em-soft: var(--bo-surface-2, #f8fafc);
  --em-ink: var(--bo-ink, #1a1f27);
  --em-muted: var(--bo-muted, #6b7484);
  --em-accent: var(--bo-orange, #f7931e);
  --em-accent-soft: #fff4e5;
  display: grid; grid-template-columns: 236px minmax(300px, 380px) minmax(0, 1fr);
  height: calc(100vh - 150px); min-height: 520px;
  background: #fff; border: 1px solid var(--em-line); border-radius: 18px;
  box-shadow: var(--bo-shadow, 0 8px 24px rgba(24, 32, 54, .06)); overflow: hidden;
}
.em-ic { flex: 0 0 auto; display: block; }
.em-grow { flex: 1 1 auto; min-width: 0; }
.em-ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.email__shell button { font-family: inherit; }

/* ---------- avatars ---------- */
.em-av { --av: #f7931e; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: .95rem; color: var(--av); background: color-mix(in srgb, var(--av) 14%, #fff);
  border: 1px solid color-mix(in srgb, var(--av) 22%, #fff); }
.em-av--sm { width: 30px; height: 30px; font-size: .8rem; }
.em-av--lg { width: 46px; height: 46px; font-size: 1.1rem; }

/* ---------- sidebar ---------- */
.email__side { background: var(--em-soft); border-inline-end: 1px solid var(--em-line); padding: 16px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.em-compose { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; margin-bottom: 10px;
  border: 0; border-radius: 14px; background: var(--bo-grad, linear-gradient(135deg, #f7931e, #ffc20e)); color: #231a08;
  font-weight: 800; font-size: .95rem; cursor: pointer; box-shadow: 0 8px 18px rgba(247, 147, 30, .28); transition: transform .18s, box-shadow .18s; }
.em-compose:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(247, 147, 30, .36); }
.em-compose:focus-visible, .email__folder:focus-visible, .email__mbitem:focus-visible, .email__row:focus-visible, .em-act:focus-visible, .em-iconbtn:focus-visible, .em-settings:focus-visible { outline: 2px solid var(--bo-blue-d, #1f8fbf); outline-offset: 2px; }
.em-sec { font-size: .72rem; font-weight: 800; color: var(--bo-muted-2, #8b93a1); padding: 12px 10px 4px; letter-spacing: .02em; }
.email__folders, .email__mailboxes { display: flex; flex-direction: column; gap: 2px; }
.email__folder, .email__mbitem { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 7px 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--bo-ink-2, #2c3440); font-size: .9rem; font-weight: 700;
  text-align: start; cursor: pointer; transition: background .16s, color .16s; }
.email__folder .em-ic { color: var(--em-muted); }
.email__folder:hover, .email__mbitem:hover { background: #eef1f6; }
.email__folder.on { background: var(--em-accent-soft); color: #9a4d00; }
.email__folder.on .em-ic { color: var(--em-accent); }
.email__mbitem.on { background: #fff; box-shadow: inset 0 0 0 1.5px var(--em-line), 0 1px 2px rgba(24, 32, 54, .05); }
.em-count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--em-accent); color: #fff; font-size: .74rem; font-weight: 800; display: grid; place-items: center; }
.em-mb-txt { display: flex; flex-direction: column; line-height: 1.25; }
.em-mb-txt b { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-mb-txt small { font-size: .74rem; color: var(--em-muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-warn { color: var(--bo-amber, #d97706); }
.em-side-empty { font-size: .84rem; color: var(--em-muted); padding: 8px 10px; }
.em-settings { margin-top: auto; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 10px; border: 1px dashed #d3d8e1;
  border-radius: 10px; background: transparent; color: var(--em-muted); font-size: .84rem; font-weight: 700; cursor: pointer; transition: all .16s; }
.em-settings:hover { border-color: var(--bo-blue, #29abe2); color: var(--bo-blue-d, #1f8fbf); background: #fff; }

/* ---------- message list ---------- */
.email__list { display: flex; flex-direction: column; min-height: 0; border-inline-end: 1px solid var(--em-line); }
.em-list-h { padding: 16px 16px 12px; border-bottom: 1px solid var(--em-line); display: flex; flex-direction: column; gap: 10px; }
.em-list-title { display: flex; align-items: center; gap: 8px; }
.em-list-title h2 { font-size: 1.2rem; font-weight: 800; color: var(--em-ink); }
.em-list-title > span { font-size: .78rem; color: var(--em-muted); font-weight: 700; background: var(--em-soft); border: 1px solid var(--em-line); border-radius: 999px; padding: 1px 9px; }
.em-iconbtn { margin-inline-start: auto; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--em-line); border-radius: 10px; background: #fff; color: var(--em-muted); cursor: pointer; transition: all .16s; }
.em-iconbtn:hover { color: var(--bo-blue-d, #1f8fbf); border-color: var(--bo-blue, #29abe2); }
.em-search { display: flex; align-items: center; gap: 8px; height: 40px; padding-inline: 12px; border: 1.5px solid var(--em-line); border-radius: 12px; background: var(--em-soft); color: var(--em-muted); transition: border-color .16s, background .16s; }
.em-search:focus-within { border-color: var(--em-accent); background: #fff; }
.em-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: .88rem; font-weight: 600; color: var(--em-ink); }
.em-rows { flex: 1; overflow-y: auto; }
.email__row { position: relative; display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--bo-line-2, #f0f3f7);
  background: #fff; text-align: start; cursor: pointer; transition: background .15s; color: inherit; }
.email__row:hover { background: #f8fafc; }
.email__row.on { background: var(--em-accent-soft); }
.email__row.on::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--em-accent); }
.em-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.email__row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.email__row-top b { font-size: .9rem; font-weight: 600; color: var(--bo-ink-2, #2c3440); }
.email__row-top b small { color: var(--em-muted); font-weight: 600; }
.email__row-top time { flex: 0 0 auto; font-size: .74rem; color: var(--em-muted); font-weight: 600; }
.email__row-subj { font-size: .86rem; color: var(--bo-ink-2, #2c3440); font-weight: 600; }
.email__row-snip { font-size: .8rem; color: var(--em-muted); }
.email__row.unread .email__row-top b, .email__row.unread .email__row-subj { font-weight: 800; color: var(--em-ink); }
.email__row.unread .email__row-top time { color: #b45a00; font-weight: 800; }
.email__row.unread::after { content: ""; position: absolute; top: 19px; inset-inline-end: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--em-accent); }
.em-row-flags { display: flex; flex-direction: column; gap: 6px; align-items: center; color: var(--em-muted); padding-top: 22px; }
.em-row-flags:empty { display: none; }
.em-star { color: #eab308; }
.em-star .em-ic, .em-act.is-on .em-ic { fill: currentColor; }

/* ---------- reading pane ---------- */
.email__detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #fff; }
.em-detail-bar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--em-line); }
.email__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; }
.em-act { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--em-line); border-radius: 10px;
  background: #fff; color: var(--bo-ink-2, #2c3440); font-size: .84rem; font-weight: 700; cursor: pointer; transition: all .16s; }
.em-act:hover { border-color: var(--bo-blue, #29abe2); color: var(--bo-blue-d, #1f8fbf); background: #f5fbfe; }
.em-act--icon { width: 36px; padding: 0; justify-content: center; }
.em-act--icon span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.em-act.is-on { color: #ca8a04; border-color: #fde68a; background: #fffbeb; }
.em-act--danger:hover { border-color: #fecaca; color: var(--bo-red, #dc2626); background: #fef2f2; }
.em-read { flex: 1; overflow-y: auto; padding: 22px 26px 30px; }
.em-subj { font-size: 1.35rem; font-weight: 800; line-height: 1.45; color: var(--em-ink); margin-bottom: 16px; overflow-wrap: anywhere; }
.em-from { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--bo-line-2, #f0f3f7); }
.em-from-txt { flex: 1; min-width: 0; font-size: .88rem; line-height: 1.5; }
.em-from-txt b { color: var(--em-ink); font-size: .95rem; }
.em-addr, .em-to { color: var(--em-muted); font-size: .82rem; overflow-wrap: anywhere; }
.em-addr { display: block; width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-mb-txt small[dir="ltr"] { align-self: flex-start; max-width: 100%; }
.em-when { flex: 0 0 auto; align-self: flex-start; font-size: .8rem; color: var(--em-muted); font-weight: 600; direction: ltr; }
.email__body { margin-top: 18px; line-height: 1.75; font-size: .95rem; color: var(--bo-ink-2, #2c3440); overflow-wrap: anywhere; unicode-bidi: isolate; text-align: start; }
.email__body img { max-width: 100%; height: auto; }
.email__body table { max-width: 100%; }
.em-plain { white-space: pre-wrap; }
.email-blocked-image { display: inline-block; padding: 2px 8px; border: 1px dashed #c3c9d4; border-radius: 6px; font-size: 11px; color: var(--em-muted); }
.em-att-h { display: flex; align-items: center; gap: 6px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--bo-line-2, #f0f3f7); font-size: .82rem; font-weight: 800; color: var(--em-muted); }
.email__attachments { margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.em-file { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--em-line); border-radius: 12px; text-decoration: none; color: inherit; transition: all .16s; min-width: 0; }
.em-file:hover { border-color: var(--bo-blue, #29abe2); background: #f5fbfe; }
.em-file-ic { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: #eaf6fc; color: var(--bo-blue-d, #1f8fbf); font-size: .66rem; font-weight: 800; }
.em-file-txt { display: flex; flex-direction: column; min-width: 0; }
.em-file-txt b { font-size: .84rem; }
.em-file-txt small { font-size: .74rem; color: var(--em-muted); }

/* ---------- empty / onboarding states ---------- */
.em-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 24px; text-align: center; color: var(--bo-muted-2, #8b93a1); }
.em-empty b { color: var(--bo-ink-2, #2c3440); font-size: 1rem; }
.em-empty span { font-size: .85rem; max-width: 300px; line-height: 1.6; }
.em-empty > .em-ic { color: #cdd3dd; margin-bottom: 4px; }
.em-empty--list { padding-block: 56px; }
.em-onboard { max-width: 520px; margin: 6vh auto; padding: 36px 28px; text-align: center; background: #fff; border: 1px solid var(--bo-line, #e6e9ef); border-radius: 20px; box-shadow: var(--bo-shadow, 0 8px 24px rgba(24, 32, 54, .06)); }
.em-onboard-ic { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 22px; display: grid; place-items: center; background: #fff4e5; color: var(--bo-orange, #f7931e); }
.em-onboard-ic--err { background: #fef2f2; color: var(--bo-red, #dc2626); }
.em-onboard h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 8px; }
.em-onboard p { color: var(--bo-muted, #6b7484); line-height: 1.7; margin-bottom: 18px; font-size: .92rem; overflow-wrap: anywhere; }
.em-onboard .btn { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- windows (compose / link / settings) ---------- */
.em-modal { width: min(560px, 100%); }
.em-modal--wide { width: min(720px, 100%); }
.em-mh { display: flex; align-items: center; gap: 8px; }
.em-mh .em-ic { color: var(--bo-orange, #f7931e); }
.modal__h .x { display: grid; place-items: center; width: 36px; height: 36px; }
.em-mb { display: flex; flex-direction: column; gap: 14px; }
.em-hint { font-size: .86rem; color: var(--bo-muted, #6b7484); }
.em-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.em-grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.em-modal .fld { margin-bottom: 0; }
.em-modal .fld input, .em-modal .fld select { width: 100%; min-width: 0; height: 44px; border: 1.5px solid var(--bo-line, #e6e9ef); border-radius: 11px; padding: 0 12px; font: inherit; font-size: .9rem; font-weight: 600; background: #fff; outline: none; }
.em-modal .fld input:focus, .em-modal .fld select:focus { border-color: var(--bo-orange, #f7931e); box-shadow: 0 0 0 3px rgba(247, 147, 30, .15); }

/* compose: header fields read as one sheet, like a real mail client */
.em-compose-f { border: 1.5px solid var(--bo-line, #e6e9ef); border-radius: 14px; overflow: hidden; }
.em-cf { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 46px; border-bottom: 1px solid var(--bo-line-2, #f0f3f7); }
.em-cf:last-child { border-bottom: 0; }
.em-cf:focus-within { background: #fffbf5; }
.em-cf > span { flex: 0 0 64px; font-size: .8rem; font-weight: 800; color: var(--bo-muted, #6b7484); }
.em-cf input, .em-cf select { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: transparent; font: inherit; font-size: .9rem; font-weight: 600; color: var(--bo-ink, #1a1f27); }
.em-cf input[dir="ltr"]::placeholder { text-align: start; }
.em-body-input { width: 100%; min-height: 220px; resize: vertical; border: 1.5px solid var(--bo-line, #e6e9ef); border-radius: 14px; padding: 14px; font: inherit; font-size: .95rem; line-height: 1.7; outline: none; }
.em-body-input:focus { border-color: var(--bo-orange, #f7931e); box-shadow: 0 0 0 3px rgba(247, 147, 30, .15); }
.em-attach-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.em-attach { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 1.5px dashed #c9d0db; border-radius: 10px; color: var(--bo-ink-2, #2c3440); font-size: .85rem; font-weight: 700; cursor: pointer; transition: all .16s; }
.em-attach:hover, .em-attach:focus-within { border-color: var(--bo-blue, #29abe2); color: var(--bo-blue-d, #1f8fbf); background: #f5fbfe; }
.em-attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.em-chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.em-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 220px; height: 30px; padding: 0 10px; border-radius: 999px; background: #eaf6fc; color: var(--bo-blue-d, #1f8fbf); font-size: .78rem; font-weight: 700; }
.em-send { display: inline-flex; align-items: center; gap: 6px; }
.em-modal .modal__f .btn { min-height: 42px; }

/* settings */
.em-mb-list { display: flex; flex-direction: column; gap: 8px; }
.email__mb-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--bo-line, #e6e9ef); border-radius: 14px; background: var(--bo-surface-2, #f8fafc); flex-wrap: wrap; }
.em-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.em-tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: #fff; border: 1px solid var(--bo-line, #e6e9ef); color: var(--bo-muted, #6b7484); }
.em-tag--ok { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.em-tag--warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.em-tag--err { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.em-mb-tests { display: flex; gap: 6px; flex-wrap: wrap; }
.em-mb-tests .btn { display: inline-flex; align-items: center; gap: 5px; }
.em-form-h { display: flex; align-items: center; gap: 6px; font-size: 1rem; font-weight: 800; padding-top: 14px; border-top: 1px solid var(--bo-line, #e6e9ef); }
.em-srv { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--bo-line-2, #f0f3f7); border-radius: 14px; background: var(--bo-surface-2, #f8fafc); }
.em-srv > b { font-size: .85rem; }
.em-check { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--bo-line, #e6e9ef); border-radius: 12px; cursor: pointer; }
.em-check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--bo-orange, #f7931e); }
.em-check span { display: flex; flex-direction: column; }
.em-check small { color: var(--bo-muted, #6b7484); font-size: .8rem; }

/* The back button only belongs to the phone layout, where the message replaces the list. */
.email__back { display: none; }

@media (max-width: 1440px) and (min-width: 901px) {
  .email__shell { grid-template-columns: 210px minmax(260px, 330px) minmax(0, 1fr); }
  .em-act:not(.em-act--icon) span { display: none; }
  .em-act:not(.em-act--icon) { width: 36px; padding: 0; justify-content: center; }
}

@media (max-width: 900px) {
  .email__shell { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; border-radius: 16px; }

  /* Folders and mailboxes become compact scrolling strips above the list. */
  .email__side { border-inline-end: 0; border-bottom: 1px solid var(--em-line); padding: 12px; gap: 8px; overflow: visible; }
  .em-sec { display: none; }
  .em-compose { margin-bottom: 0; }
  .email__mailboxes, .email__folders { flex-direction: row; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .email__mailboxes::-webkit-scrollbar, .email__folders::-webkit-scrollbar { display: none; }
  .email__mbitem, .email__folder { flex: 0 0 auto; width: auto; white-space: nowrap; border: 1px solid var(--em-line); border-radius: 999px; background: #fff; min-height: 40px; padding-inline: 12px; }
  .email__mbitem .em-av { width: 24px; height: 24px; font-size: .7rem; }
  .em-mb-txt small { display: none; }
  .em-settings { margin-top: 0; justify-content: center; }

  .email__list { border-inline-end: 0; }
  .em-rows { overflow: visible; }
  .em-list-h { padding: 14px 12px 10px; }
  .email__row { padding: 13px 12px; }

  /* One pane at a time: the list until a message is opened, then the message. */
  .email__shell--reading .email__side, .email__shell--reading .email__list { display: none; }
  .email__shell:not(.email__shell--reading) .email__detail { display: none; }
  .email__back { display: inline-flex; }
  .em-detail-bar { padding: 10px 12px; position: sticky; top: 0; background: #fff; z-index: 2; flex-wrap: wrap; }
  .em-act:not(.em-act--icon):not(.email__back) span { display: none; }
  .em-act:not(.em-act--icon):not(.email__back) { width: 40px; padding: 0; justify-content: center; }
  .em-act { height: 40px; }
  .em-act--icon { width: 40px; }
  .em-read { padding: 16px 14px 24px; overflow: visible; }
  .em-subj { font-size: 1.15rem; }
  .em-from { flex-wrap: wrap; }
  .em-when { width: 100%; text-align: end; }

  .em-grid2, .em-grid3 { grid-template-columns: minmax(0, 1fr); }
  .em-cf > span { flex-basis: 52px; }
  .em-mb-tests { width: 100%; }
  .em-mb-tests .btn { flex: 1; justify-content: center; min-height: 40px; }
  .em-modal .modal__f { flex-wrap: wrap; }
  .em-modal .modal__f .btn { flex: 1 1 auto; }
}
