/* Dashboard → Email (mail.js): the company mailbox. Loaded after gilded.css; uses its colours and glass
   (--card, --ink, --muted, --edge, --glass…), with plain fallbacks if gilded.css is ever taken out.
   Phones (≤860px): one pane at a time, buttons 44px, fields 16px text, like the rest of the dashboard. */

.wm { display: grid; gap: 14px; min-width: 0; }
.wm svg { width: 18px; height: 18px; flex: none; }
.wm .pp-tab svg { width: 16px; height: 16px; opacity: .8; }
.wm-show-s { display: none; }

/* ---------- Two panes: the list and the email ---------- */
.wm-two { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; height: min(78vh, 900px); min-height: 540px; }
.wm-list, .wm-read { min-width: 0; min-height: 0; border-radius: 22px; background: var(--card); border: 1px solid var(--edge); }
.wm-list { display: flex; flex-direction: column; overflow: hidden; }
.wm-list[aria-busy="true"] { opacity: .6; transition: opacity .2s; }
.wm-read { overflow-y: auto; scrollbar-width: thin; }
@media (min-width: 861px) {
  .dash-body :is(.wm-list, .wm-read) { background: var(--glass, var(--card)); border-color: var(--glass-line, var(--edge)); box-shadow: var(--glass-shadow, none); }
}

/* Search and tools */
.wm-find { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 12px 6px; }
.wm-find-in { flex: 1 1 200px; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--glass-2, rgba(201,162,74,.08)); border: 1px solid var(--edge); color: var(--muted); }
.wm-find-in:focus-within { border-color: var(--accent); }
.wm-find-in input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; outline: none; }
.wm-deep { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.wm-tools { display: flex; align-items: center; gap: 6px; padding: 4px 10px 8px 12px; border-bottom: 1px solid var(--edge); min-height: 48px; }
.wm-chips, .wm-bulk { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.wm-chips[hidden], .wm-bulk[hidden], .wm [hidden] { display: none !important; }
.wm-chip { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); font: 600 12.5px var(--sans, inherit); cursor: pointer; white-space: nowrap; }
.wm-chip:hover { color: var(--ink); background: rgba(201,162,74,.12); }
.wm-chip[aria-pressed="true"] { color: var(--ink); border-color: var(--edge-strong); background: rgba(201,162,74,.14); }
.wm-bulk-n { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; margin-right: 4px; }
.wm-tb { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--ink); font: 500 12.5px var(--sans, inherit); cursor: pointer; white-space: nowrap; }
.wm-tb:hover { background: rgba(201,162,74,.14); }
.wm-tb:disabled { opacity: .45; cursor: default; }
.wm-tb svg { width: 17px; height: 17px; }
.wm-tb--danger { color: #b3261e; }
.dark-ui .wm-tb--danger, .dark-ui .wm-tb--danger svg { color: #ff9b91; }
.wm-tb[aria-pressed="true"] svg { fill: #e1bb62; stroke: #b98a2e; }
.wm-refresh { margin-left: auto; }

/* Checkboxes */
.wm-check { display: grid; place-items: center; width: 34px; height: 34px; flex: none; cursor: pointer; }
.wm-check input { width: 17px; height: 17px; margin: 0; accent-color: #b98a2e; cursor: pointer; }

/* Rows */
.wm-rows { list-style: none; margin: 0; padding: 4px 6px 8px; overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; }
.wm-row { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 2px; border-radius: 14px; }
.wm-row + .wm-row { margin-top: 1px; }
.wm-row:hover { background: rgba(201,162,74,.08); }
.wm-row.is-open { background: rgba(201,162,74,.16); box-shadow: inset 3px 0 0 #c9a24a; }
.wm-row-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who meta" "subj subj"; gap: 2px 10px; padding: 9px 4px 9px 0; color: var(--muted); text-decoration: none; min-width: 0; }
.wm-who { grid-area: who; display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-subj { grid-area: subj; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-meta { grid-area: meta; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.wm-mi svg { width: 14px; height: 14px; opacity: .75; }
.wm-row.is-unread .wm-who { font-weight: 700; }
.wm-row.is-unread .wm-subj { color: var(--ink); font-weight: 600; }
.wm-dot { width: 8px; height: 8px; border-radius: 50%; background: #d6a23c; flex: none; box-shadow: 0 0 8px rgba(214,162,60,.7); }
.wm-star { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.wm-star svg { width: 17px; height: 17px; }
.wm-star:hover { color: var(--ink); background: rgba(201,162,74,.12); }
.wm-star[aria-pressed="true"] svg { fill: #e1bb62; stroke: #b98a2e; }
.wm-row-link:focus-visible, .wm-star:focus-visible, .wm-tb:focus-visible, .wm-chip:focus-visible, .wm-att:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wm-empty { margin: 0; padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.wm-pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--edge); font-size: 12.5px; color: var(--muted); }
.wm-pager span { margin-right: auto; }

/* ---------- The email ---------- */
.wm-pick, .wm-loading, .wm-big { display: grid; place-items: center; align-content: center; gap: 12px; min-height: 100%; padding: 30px; text-align: center; color: var(--muted); }
.wm-pick svg, .wm-big svg { width: 44px; height: 44px; opacity: .45; }
.wm-pick p, .wm-big p { margin: 0; max-width: 26em; }
.wm-msg { display: grid; gap: 14px; padding: 18px 20px 24px; min-width: 0; }
.wm-msg-head { display: grid; gap: 12px; min-width: 0; }
.wm-back { display: none; align-items: center; gap: 6px; width: max-content; min-height: 40px; color: var(--accent); font-size: 14px; font-weight: 600; text-decoration: none; }
.wm-subject { margin: 0; font-family: var(--serif, inherit); font-size: clamp(22px, 2.2vw, 28px); line-height: 1.2; color: var(--ink); overflow-wrap: anywhere; }
.wm-from { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.wm-face { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 700; font-size: 16px; color: #fff; background: hsl(var(--h) 42% 40%); }
.wm-from-who { min-width: 0; font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.wm-addr { color: var(--muted); }
.wm-from-who small { display: grid; gap: 2px; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.wm-from-who small b { font-weight: 600; color: var(--ink); opacity: .8; }
.wm-when { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.wm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--edge); }
.wm-actions .dash-pill svg { width: 17px; height: 17px; }
.wm-act-gap { flex: 1; }
.wm-move select { min-height: 34px; padding: 0 28px 0 12px; border-radius: 999px; border: 1px solid var(--edge-strong); color: var(--ink); background: transparent; font: 500 12.5px var(--sans, inherit); appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23b98a2e' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.wm-move select option { color: #1d160e; background: #fffdf8; }
.wm-held, .wm-warnline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; padding: 10px 14px; border-radius: 14px; font-size: 13px; color: var(--ink); background: rgba(201,162,74,.12); border: 1px solid var(--edge-strong); }
.wm-held span { flex: 1 1 220px; }
.wm-warnline { background: rgba(179,38,30,.1); border-color: rgba(179,38,30,.3); }
.wm-held svg, .wm-warnline svg { width: 20px; height: 20px; }
/* The email itself: on white paper, the way it was written (dark mode too) */
.wm-body { min-width: 0; }
.wm-frame { display: block; width: 100%; min-height: 120px; border: 0; border-radius: 14px; background: #fff; box-shadow: 0 0 0 1px var(--edge); color-scheme: light; }
.wm-text { padding: 2px 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.6; color: var(--ink); }
.wm-text a { color: var(--accent); }
.wm-q { color: var(--muted); }
.wm-atts h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.wm-atts ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.wm-att { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 6px 14px; border-radius: 14px; border: 1px solid var(--edge-strong); background: var(--glass-2, transparent); color: var(--ink); font: 500 13px var(--sans, inherit); cursor: pointer; text-align: left; }
.wm-att:hover { background: rgba(201,162,74,.14); }
.wm-att[aria-busy="true"] { opacity: .6; cursor: progress; }
.wm-att-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22em; }
.wm-att small { color: var(--muted); white-space: nowrap; }
.wm-att.is-risky { border-color: rgba(179,38,30,.45); }
.wm-att.is-risky > svg:first-child { color: #b3261e; }
.dark-ui .wm-att.is-risky > svg:first-child { color: #ff9b91; }
.wm-status { margin: 0; }

/* ---------- Writing ---------- */
.wm-dlg { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 16px; background: rgba(8,6,10,.55); }
.wm-compose { display: flex; flex-direction: column; width: min(780px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); border-radius: 22px; background: var(--solid, var(--card)); color: var(--ink); border: 1px solid var(--glass-line, var(--edge)); box-shadow: 0 40px 90px -30px rgba(0,0,0,.75); overflow: hidden; }
.wm-compose svg { width: 18px; height: 18px; flex: none; }
.wm-c-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 10px 20px; border-bottom: 1px solid var(--edge); }
.wm-c-head h2 { margin: 0; font-family: var(--serif, inherit); font-size: 22px; color: var(--ink); }
.wm-c-fields { display: grid; grid-template-columns: minmax(0, 1fr); }
.wm-c-row { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 46px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--edge); }
.wm-c-row label { flex: none; width: 4.2em; font-size: 13px; color: var(--muted); }
.wm-c-row input, .wm-c-row select { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; outline: none; }
.wm-c-row select { width: 100%; text-overflow: ellipsis; cursor: pointer; }
.wm-c-row select option { color: #1d160e; background: #fffdf8; }
.wm-c-row:focus-within { box-shadow: inset 2px 0 0 var(--accent); }
.wm-link { flex: none; border: 0; background: none; color: var(--accent); font: 600 12.5px var(--sans, inherit); cursor: pointer; min-height: 36px; padding: 0 4px; }
.wm-compose textarea { flex: 1 1 260px; min-height: 200px; width: 100%; padding: 16px 20px; border: 0; resize: none; background: transparent; color: var(--ink); font: inherit; font-size: 15px; line-height: 1.55; outline: none; }
.wm-c-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.wm-c-files:not(:empty) { padding: 8px 16px; border-top: 1px solid var(--edge); }
.wm-c-file { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 36px; padding: 0 6px 0 10px; border-radius: 12px; border: 1px solid var(--edge-strong); font-size: 12.5px; cursor: default; }
.wm-c-file input { margin: 0 2px 0 0; accent-color: #b98a2e; }
.wm-c-file span { min-width: 0; max-width: 18em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-c-file small { color: var(--muted); }
.wm-x { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.wm-x svg { width: 14px; height: 14px; }
.wm-x:hover { color: var(--ink); background: rgba(201,162,74,.14); }
.wm-c-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px 16px; border-top: 1px solid var(--edge); }
.wm-attach { position: relative; cursor: pointer; }
.wm-attach:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.wm-c-size { font-size: 12px; color: var(--muted); }
.wm-c-size.is-over { color: #b3261e; font-weight: 600; }
.dark-ui .wm-c-size.is-over { color: #ff9b91; }
.wm-discard { margin-left: auto; color: var(--muted); }
.wm-c-note { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 20px; font-size: 13px; color: var(--ink); background: rgba(179,38,30,.08); border-bottom: 1px solid var(--edge); }
.wm-compose .form-status { margin: 0; padding: 0 20px 12px; }
.wm-compose .form-status:empty { display: none; }

/* ---------- Mail settings ---------- */
.wm-set { max-width: 760px; }
.wm-set-back { margin: 0; }
.wm-set-back svg { width: 16px; height: 16px; }
.wm-card { display: grid; gap: 12px; }
.wm-card > * { margin: 0; }
.wm-card-title { font-family: var(--serif, inherit); font-size: 24px; color: var(--ink); }
.wm-lead { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.wm-card p, .wm-card li { font-size: 14.5px; line-height: 1.55; }
.wm-state { display: inline-flex; align-items: center; gap: 8px; width: max-content; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; }
.wm-state-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.wm-state.is-on { color: #1f7a5c; background: rgba(31,154,131,.14); }
.wm-state.is-off { color: #8a5a12; background: rgba(214,162,60,.16); }
.dark-ui .wm-state.is-on { color: #7fe0c8; }
.dark-ui .wm-state.is-off { color: #f0d38c; }
.wm-form { display: grid; gap: 10px; max-width: 520px; }
.wm-form .dc-label { margin: -4px 0 4px; }
.wm-row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.wm-row-btns svg, .wm-card .dash-pill svg { width: 17px; height: 17px; }
.wm-note { padding: 10px 14px; border-radius: 12px; background: rgba(201,162,74,.12); }
.wm-help ul { display: grid; gap: 6px; margin: 0; padding-left: 1.2em; color: var(--muted); }
.wm-help a { color: var(--accent); }
.wm-off summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; color: var(--ink); }
.wm-off[open] { display: grid; gap: 10px; }
.wm-error { max-width: 640px; }
.wm-error h2 { font-family: var(--serif, inherit); font-size: 24px; color: var(--ink); }

/* ---------- Computers a little narrower ---------- */
@media (max-width: 1180px) {
  .wm-two { grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); }
  /* icon-only buttons: the words stay for screen readers and the tooltip */
  .wm-actions .dash-pill span, .wm-actions .wm-tb span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Phones and small tablets: one pane at a time ---------- */
@media (max-width: 860px) {
  .wm { gap: 12px; }
  .wm-hide-s { display: none !important; }
  .wm-show-s { display: inline; }
  .wm-bar { gap: 10px; }
  .wm-bar .pp-tabs { order: 2; width: 100%; }
  .wm-bar .pp-bar-end { order: 1; width: 100%; justify-content: flex-end; }
  .wm-bar .pp-bar-end .dash-pill { flex: 0 0 auto; min-height: 44px; min-width: 44px; font-size: 14px; }
  .wm-bar .pp-bar-end [data-wm-write] { flex: 1 1 auto; }
  .wm-two { display: block; height: auto; min-height: 0; }
  .wm-list, .wm-read { border-radius: 18px; }
  .dash-body :is(.wm-list, .wm-read) { background: var(--solid, var(--card)); border-color: var(--glass-line, var(--edge)); }
  .wm-list { overflow: visible; }
  .wm-rows { overflow: visible; padding: 4px 4px 8px; }
  .wm-read { overflow: visible; display: none; }
  .wm[data-open="1"] .wm-list { display: none; }
  .wm[data-open="1"] .wm-read { display: block; }
  .wm-find-in { min-height: 48px; }
  .wm-find-in input { font-size: 16px; }
  .wm-deep { min-height: 36px; font-size: 13px; }
  .wm-check { width: 44px; height: 44px; }
  .wm-check input { width: 20px; height: 20px; }
  .wm-chip { min-height: 36px; font-size: 13px; }
  .wm-tb { min-height: 44px; min-width: 44px; justify-content: center; font-size: 14px; }
  .wm-bulk .wm-tb span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .wm-star { width: 44px; height: 44px; }
  .wm-row-link { padding: 11px 2px 11px 0; }
  .wm-who { font-size: 15px; }
  .wm-subj { font-size: 13.5px; }
  .wm-meta { font-size: 12px; }
  .wm-pager .wm-tb { min-width: 0; padding: 0 14px; }
  .wm-msg { padding: 12px 14px 20px; }
  .wm-back { display: inline-flex; min-height: 44px; }
  .wm-from { grid-template-columns: auto minmax(0, 1fr); }
  .wm-when { grid-column: 2; }
  .wm-actions .dash-pill { min-height: 44px; font-size: 14px; }
  .wm-act-gap { display: none; }
  .wm-move select { min-height: 44px; font-size: 14px; }
  .wm-text { font-size: 15px; }
  .wm-atts li { width: 100%; }
  .wm-att { min-height: 48px; width: 100%; }
  .wm-att-name { max-width: none; flex: 1; }
  .wm-dlg { padding: 0; place-items: stretch; }
  .wm-compose { width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0; }
  .wm-c-row { min-height: 48px; padding: 0 12px 0 16px; }
  .wm-c-row input, .wm-c-row select { min-height: 48px; font-size: 16px; }
  .wm-c-row label { font-size: 14px; }
  .wm-link { min-height: 44px; font-size: 14px; }
  .wm-compose textarea { font-size: 16px; padding: 14px 16px; }
  .wm-c-head { padding: 8px 8px 8px 16px; }
  .wm-c-head .wm-tb { width: 44px; height: 44px; }
  .wm-c-foot .dash-pill { min-height: 44px; font-size: 14px; }
  .wm-discard { min-height: 44px; font-size: 14px; }
  .wm-x { width: 36px; height: 36px; }
  .wm-c-file { min-height: 40px; }
  .wm-form .field input { font-size: 16px; }
  .wm-card .dash-pill { min-height: 44px; font-size: 14px; }
  .wm-off summary { min-height: 44px; }
  .wm-card-title { font-size: 22px; }
  .wm-card p, .wm-card li { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) { .wm-list[aria-busy="true"] { transition: none; } }
