/* Compose window, the editor, address chips, attachment chips with a progress ring, and the flying envelope. */
.compose { position: fixed; z-index: 60; bottom: max(16px, var(--sab)); inset-inline-end: 24px; width: min(580px, calc(100vw - 48px)); height: min(640px, calc(100dvh - 96px));
  display: flex; flex-direction: column; border-radius: 26px; overflow: hidden; box-shadow: var(--shadow-3), var(--inner);
  opacity: 0; transform: perspective(1000px) translateZ(-90px) rotateX(9deg); transform-origin: 50% 100%;
  transition: opacity .3s ease, transform .5s var(--ease), width .38s var(--ease), height .38s var(--ease), border-radius .3s; }
.compose.in { opacity: 1; transform: none; }
.compose.out { opacity: 0; transform: perspective(1000px) translateZ(-70px) scale(.97); }
.compose.min { height: 58px; width: min(340px, calc(100vw - 48px)); }
.compose.min .cw-body, .compose.min .cw-foot { display: none; }
.compose.min .cw-head { cursor: pointer; border-block-end: 0; }
.compose.max { top: 5dvh; bottom: auto; inset-inline: 0; margin-inline: auto; width: min(1000px, calc(100vw - 64px)); height: 88dvh; }
.cw-scrim { position: fixed; inset: 0; z-index: 59; background: rgba(20, 6, 32, .32); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity .3s; }
.cw-scrim.on { opacity: 1; pointer-events: auto; }

.cw-head { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 6px 8px 6px 20px; padding-inline: 20px 8px; border-block-end: 1px solid var(--line); }
.cw-title { flex: 1; min-width: 0; font: 700 16px/1.3 var(--display); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-saved { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.cw-head-tools { display: flex; align-items: center; gap: 0; flex: none; }
.cw-send-mini { display: none; }
.cw-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.cw-row { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 3px 14px 3px 20px; padding-inline: 20px 14px; border-block-end: 1px solid var(--line); }
.cw-k { flex: none; min-width: 44px; color: var(--muted); font-size: 14px; }
.chips { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-block: 5px; cursor: text; }
.chip-input { flex: 1; min-width: 140px; height: 36px; border: 0; background: transparent; font-size: 16px; outline: none; }
.chip { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; height: 32px; padding-inline: 12px 3px; border-radius: 999px; font-size: 14px; font-weight: 550;
  background: var(--sel); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent); animation: tm-chip .3s var(--ease) both; }
@keyframes tm-chip { from { opacity: 0; transform: scale(.85); } }
.chip.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.chip-x:hover { background: var(--hover); color: var(--text); }
.chip-x svg { width: 14px; height: 14px; }
.cw-reveal { display: flex; flex: none; }
.cw-reveal button { min-height: 36px; padding: 0 10px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.cw-reveal button:hover { background: var(--hover); color: var(--text); }
.cw-subject { flex: 1; min-width: 0; height: 44px; border: 0; background: transparent; font-size: 16px; font-weight: 600; outline: none; }
.cw-subject::placeholder { color: var(--muted); font-weight: 500; }

.editor { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 200px; }
.ed-bar { display: flex; flex-wrap: wrap; gap: 1px; padding: 5px 12px; border-block-end: 1px solid var(--line); }
.editor.no-bar .ed-bar { display: none; }
.ed-bar .icon-btn[aria-pressed="true"] { background: var(--sel); color: var(--accent); }
.ed-area { position: relative; flex: 1; min-height: 150px; padding: 14px 20px 18px; font-size: 16px; line-height: 1.6; outline: none; overflow-wrap: anywhere; }
.ed-area blockquote { margin: 6px 0; padding-inline-start: 12px; border-inline-start: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); color: var(--muted); }
.ed-area ul, .ed-area ol { margin: 4px 0; padding-inline-start: 24px; }
.ed-area a { color: var(--accent); }
.editor.empty .ed-area::before { content: attr(data-placeholder); position: absolute; inset-inline-start: 20px; top: 14px; color: var(--muted); pointer-events: none; }
.editor.compact { min-height: 0; border-radius: 16px; background: var(--field); border: 1px solid var(--glass-hair); overflow: hidden; }
.editor.compact .ed-area { min-height: 110px; padding: 12px 14px; }
.editor.compact.empty .ed-area::before { inset-inline-start: 14px; top: 12px; }
.ed-link { position: absolute; z-index: 5; inset-inline-start: 12px; display: flex; gap: 8px; width: min(400px, calc(100% - 24px)); padding: 8px; border-radius: 18px; box-shadow: var(--shadow-2); }
.ed-link .input { min-height: 42px; }

.cw-atts { display: flex; flex-wrap: wrap; gap: 8px; padding-inline: 20px; }
.cw-atts:not(:empty) { padding-block: 10px; }
.cw-att { min-height: 52px; max-width: 250px; padding-inline-end: 4px; }
.cw-att.bad { border-color: var(--bad); }
.att-tile.up { background: var(--field); color: var(--accent); box-shadow: inset 0 0 0 1px var(--glass-hair); }
.ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--accent); stroke-dasharray: 62.8; stroke-dashoffset: 62.8; stroke-linecap: round; transition: stroke-dashoffset .25s ease; }
.cw-error { padding-inline: 20px; color: var(--bad); font-size: 14px; font-weight: 500; }
.cw-error:not(:empty) { padding-block: 8px 10px; }
.cw-error.flash { animation: tm-err .9s ease; }
@keyframes tm-err { 0%, 30% { color: #fff; background: var(--bad); } }

.cw-foot { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-block-start: 1px solid var(--line); }
.cw-send { min-width: 132px; min-height: 48px; border-radius: 15px; font-size: 15.5px; }
.cw-send > span:not(.gleam), .cw-send > svg { position: relative; z-index: 1; }
.cw-send.busy svg { animation: tm-pulse .9s ease-in-out infinite; }
@keyframes tm-pulse { 50% { opacity: .35; } }
.cw-spacer { flex: 1; }
.fmt-a { font: 800 17px/1 var(--display); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.cw-drop { position: absolute; inset: 8px; z-index: 6; display: none; place-items: center; align-content: center; gap: 10px; border-radius: 22px;
  border: 2px dashed var(--accent); color: var(--accent); font-weight: 700; background: color-mix(in srgb, var(--accent) 9%, var(--glass-strong)); }
.cw-drop svg { width: 34px; height: 34px; }
.compose.dragging .cw-drop { display: grid; }

.fly-layer { position: fixed; inset: 0; z-index: 75; pointer-events: none; }
.fly-layer canvas { display: block; width: 100%; height: 100%; }

@media (max-width: 1099px) { .compose { inset-inline-end: 16px; } }
@media (max-width: 699px) {
  .compose, .compose.max { inset: 0; width: 100%; height: 100dvh; margin: 0; border-radius: 0; border: 0; padding-top: var(--sat); transform-origin: 50% 100%; }
  .compose.min { height: 100dvh; width: 100%; }
  .cw-min, .cw-max { display: none; }
  .cw-send-mini { display: inline-flex; margin-inline: 4px 2px; padding-inline: 14px 12px; border-radius: 13px; }
  .cw-send-mini > span:not(.gleam), .cw-send-mini > svg { position: relative; z-index: 1; }
  .cw-send-mini svg { width: 17px; height: 17px; }
  .cw-send-mini.busy svg { animation: tm-pulse .9s ease-in-out infinite; }
  .cw-foot .cw-send { display: none; }
  .cw-foot { padding-block-end: calc(10px + var(--sab)); }
  .cw-head { padding-inline: 16px 4px; }
  .cw-row { padding-inline: 16px 8px; }
  .ed-area { padding-inline: 16px; }
}
