/* A letter sliding in over a card: the card stays visible on the left.
   Same tokens as the deal card: surface-2 background, white section cards, 16px radius, ink primary buttons. */
#mail-slide-root:empty{display:none}
.ms-overlay{position:fixed;inset:0;z-index:1200;background:rgb(15 23 42 / 34%);display:flex;justify-content:flex-end;animation:ms-fade .18s ease-out}
.ms-panel{position:relative;width:min(900px,calc(100vw - 72px));height:100%;background:var(--surface-2);box-shadow:-18px 0 48px var(--shadow-strong,rgb(15 23 42 / 22%));display:flex;flex-direction:column;animation:ms-slide .24s cubic-bezier(.2,.8,.2,1)}
.ms-close{position:absolute;left:-50px;top:14px;width:38px;height:38px;border-radius:50%;border:0;background:var(--surface);color:var(--ink);display:grid;place-items:center;box-shadow:0 6px 18px rgb(15 23 42 / 22%)}
.ms-close:hover{background:var(--ink);color:#fff}
.ms-close .icon{width:18px;height:18px}

/* Header: subject, deal, actions */
.ms-head{background:var(--surface);border-bottom:1px solid var(--line);padding:16px 24px 12px;display:flex;flex-direction:column;gap:12px}
.ms-head h2{margin:0;font-size:19px;line-height:1.3;font-weight:700;color:var(--ink);overflow-wrap:anywhere}
.ms-head-meta{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}
.ms-deal,.ms-count{display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:999px;font-size:12px;font-weight:600;background:var(--surface-2);border:1px solid var(--line);color:var(--secondary)}
.ms-deal .icon{width:13px;height:13px}
.ms-toolbar-row{display:flex;flex-wrap:wrap;justify-content:space-between;gap:8px}
.ms-tools-main,.ms-tools-side{display:flex;flex-wrap:wrap;gap:6px}
.ms-head .btn.small{min-height:32px;padding:6px 12px;font-size:13px;border-radius:10px}
.ms-head .btn.ghost{background:transparent;box-shadow:none;border-color:transparent}
.ms-head .btn.ghost:hover{background:var(--surface-2);border-color:var(--line)}
.ms-head .ms-danger:hover{color:var(--danger-text,#b42318)}
.ms-head .btn .icon{width:15px;height:15px}

.ms-scroll{flex:1;overflow:auto;padding:16px 24px 28px;display:flex;flex-direction:column;gap:14px}

/* The conversation */
.ms-thread{display:flex;flex-direction:column;gap:10px}
.ms-letter{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-md,14px);box-shadow:0 3px 12px rgb(29 48 85 / 5%);overflow:hidden}
.ms-letter.is-current{border-color:color-mix(in srgb,var(--accent) 45%,var(--line))}
.ms-letter-head{all:unset;box-sizing:border-box;width:100%;display:flex;gap:12px;align-items:flex-start;padding:12px 16px;cursor:pointer}
.ms-letter-head:hover{background:color-mix(in srgb,var(--surface-2) 70%,transparent)}
.ms-letter-head:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.ms-letter.is-open .ms-letter-head{border-bottom:1px solid var(--line)}
.ms-avatar{width:34px;height:34px;border-radius:50%;flex:none;display:grid;place-items:center;font-weight:700;font-size:14px;background:color-mix(in srgb,var(--accent) 14%,transparent);color:var(--accent)}
.ms-avatar.is-out{background:color-mix(in srgb,var(--ink) 10%,transparent);color:var(--ink)}
.ms-letter-meta{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}
.ms-letter-line{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.ms-letter-line strong{color:var(--ink);font-size:14px}
.ms-dir{font-size:11px;font-weight:650;padding:1px 8px;border-radius:999px;background:color-mix(in srgb,var(--accent) 12%,transparent);color:var(--accent)}
.ms-dir.is-out{background:color-mix(in srgb,var(--ink) 8%,transparent);color:var(--secondary)}
.ms-chip{display:inline-flex;align-items:center;gap:3px;font-size:12px;color:var(--muted)}
.ms-chip .icon{width:13px;height:13px}
.ms-letter-sub{font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ms-letter.is-open .ms-letter-sub{white-space:normal;overflow-wrap:anywhere}
.ms-letter-head time{font-size:12px;color:var(--muted);white-space:nowrap;padding-top:2px}
.ms-letter-body{padding:14px 16px 16px}
.ms-text{line-height:1.65;font-size:14px;color:var(--ink);overflow-wrap:anywhere}
.ms-text blockquote{margin:10px 0 0;padding:4px 0 4px 12px;border-left:3px solid var(--line);color:var(--muted)}
.ms-frame{display:block;width:100%;height:120px;border:0;background:#fff;border-radius:8px}
.ms-letter-body .mail-saved-files{margin-top:12px}

/* Reply */
.ms-compose{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-md,14px);box-shadow:0 3px 12px rgb(29 48 85 / 5%);padding:16px;display:flex;flex-direction:column;gap:10px;scroll-margin-top:12px}
.ms-compose-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px;flex-wrap:wrap}
.ms-compose-head h3{margin:0;font-size:15px;color:var(--ink)}
.ms-compose-head span{font-size:12px;color:var(--muted)}
.ms-fields{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:10px;overflow:hidden}
.ms-row{display:flex;align-items:center;gap:10px;padding:0 12px;min-height:42px;background:var(--surface)}
.ms-row+.ms-row{border-top:1px solid var(--line)}
.ms-row>span:first-child{flex:none;width:98px;font-size:13px;color:var(--muted)}
.ms-row input{flex:1;min-width:0;border:0;outline:none;background:transparent;font:inherit;font-size:14px;color:var(--ink);padding:10px 0}
.ms-row-links{display:flex;gap:10px;flex:none}
.ms-link{background:none;border:0;padding:0;color:var(--accent);font:inherit;font-size:13px}
.ms-link:hover{text-decoration:underline}
.ms-editor-shell{border:1px solid var(--line);border-radius:10px;background:var(--surface);overflow:hidden}
.ms-format{display:flex;flex-wrap:wrap;align-items:center;gap:2px;padding:5px 6px;border-bottom:1px solid var(--line);background:var(--surface-2)}
.ms-format button{min-width:30px;height:28px;border:0;border-radius:6px;background:none;font-weight:650;font-size:13px;color:var(--secondary)}
.ms-format button:hover{background:var(--surface);color:var(--accent)}
.ms-format [data-command=italic]{font-style:italic}.ms-format [data-command=underline]{text-decoration:underline}.ms-format [data-command=strikeThrough]{text-decoration:line-through}
.ms-format-gap{flex:1}
.ms-attach{display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 10px;border-radius:6px;font-size:13px;font-weight:600;color:var(--secondary);cursor:pointer}
.ms-attach:hover{background:var(--surface);color:var(--accent)}
.ms-attach .icon{width:14px;height:14px}
.ms-linkbar{display:flex;gap:6px;padding:6px;border-bottom:1px solid var(--line)}
.ms-linkbar[hidden]{display:none}
.ms-linkbar input{flex:1;min-width:0;border:1px solid var(--line);border-radius:8px;padding:6px 10px;font:inherit;font-size:13px}
.ms-editor{min-height:200px;max-height:50vh;overflow:auto;padding:14px 16px;line-height:1.6;font-size:14px;color:var(--ink);outline:none;overflow-wrap:anywhere}
.ms-editor blockquote{margin:12px 0 0;padding:4px 0 4px 12px;border-left:3px solid var(--line);color:var(--muted)}
.ms-file-list{display:flex;flex-wrap:wrap;gap:6px}
.ms-file{display:inline-flex;align-items:center;gap:6px;padding:4px 4px 4px 10px;border:1px solid var(--line);border-radius:999px;font-size:13px;background:var(--surface-2)}
.ms-file .icon{width:13px;height:13px;color:var(--muted)}
.ms-file button{border:0;background:none;width:22px;height:22px;border-radius:50%;font-size:15px;line-height:1;color:var(--muted)}
.ms-file button:hover{background:var(--surface);color:var(--danger-text,#b42318)}
.ms-compose .error-msg:empty{display:none}
.ms-compose-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.ms-compose-gap{flex:1}
.ms-compose-actions small{color:var(--muted);font-size:12px}
.ms-compose-actions .btn .icon{width:15px;height:15px}

/* In-panel confirmation (instead of the browser dialog) */
.ms-dialog-layer{position:absolute;inset:0;z-index:5;display:grid;place-items:center;padding:24px;background:rgb(15 23 42 / 28%);animation:ms-fade .14s ease-out}
.ms-dialog{width:min(420px,100%);background:var(--surface);border:1px solid var(--line);border-radius:var(--radius,16px);box-shadow:0 24px 60px rgb(15 23 42 / 28%);padding:20px 22px 18px;animation:ms-pop .16s ease-out}
.ms-dialog h3{margin:0 0 6px;font-size:17px;color:var(--ink)}
.ms-dialog p{margin:0;font-size:14px;line-height:1.55;color:var(--secondary);overflow-wrap:anywhere}
.ms-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}
.ms-dialog .btn.danger{background:var(--danger-red,#d92d20);border-color:var(--danger-red,#d92d20);color:#fff}

body.ms-open{overflow:hidden}
@keyframes ms-slide{from{transform:translateX(40px);opacity:.4}to{transform:none;opacity:1}}
@keyframes ms-fade{from{opacity:0}}
@keyframes ms-pop{from{transform:scale(.96);opacity:0}}
@media (max-width:760px){
  .ms-panel{width:100vw}
  .ms-close{left:auto;right:12px;top:12px;width:34px;height:34px;z-index:3}
  .ms-head{padding:14px 56px 10px 16px}
  .ms-scroll{padding:12px 12px 24px}
  .ms-row{flex-wrap:wrap;padding:6px 12px;gap:2px}.ms-row>span:first-child{width:100%}
  .ms-compose-actions small{display:none}
}
@media (prefers-reduced-motion:reduce){.ms-overlay,.ms-panel,.ms-dialog-layer,.ms-dialog{animation:none}}
/* The same confirmation over the whole page (deal feed, agent cards) */
.ms-dialog-layer.is-fixed{position:fixed;z-index:1300}
/* A short answer inside the confirmation (e.g. the result of a finished activity) */
.ms-dialog .pc-field{display:flex;flex-direction:column;gap:4px;margin-top:12px}
.ms-dialog .pc-field span{font-size:13px;color:var(--muted)}
.ms-dialog .pc-field textarea{width:100%;box-sizing:border-box;border:1px solid var(--line);border-radius:10px;padding:8px 10px;font:inherit;font-size:14px;resize:vertical;color:var(--ink);background:var(--surface)}
.ms-dialog .pc-field textarea:focus{outline:2px solid color-mix(in srgb,var(--accent) 40%,transparent);border-color:var(--accent)}
.ms-dialog .pc-error{color:var(--danger-text,#b42318);font-size:12px}
