/* Docked compose windows. Several can be open at once; they stack from the
   bottom-right, minimise to a title bar and can be popped out to fill the
   screen. On a phone every compose window is full screen. */

.dock {
  position: fixed; right: 16px; bottom: 0; z-index: 90;
  display: flex; align-items: flex-end; gap: 12px; flex-direction: row-reverse;
  pointer-events: none;
}
.dock > * { pointer-events: auto; }

.compose {
  width: 560px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100dvh - 80px);
  display: flex; flex-direction: column;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-3);
  animation: compose-in .16s ease;
}
@keyframes compose-in { from { transform: translateY(20px); opacity: 0; } }
.compose.is-min { height: auto; }
.compose.is-min .compose-body, .compose.is-min .compose-foot { display: none; }
.compose.is-full {
  position: fixed; inset: 24px; width: auto; height: auto; max-width: none; max-height: none;
  border-radius: var(--r-lg); border-bottom: 1px solid var(--line);
  margin: 0 auto; max-width: 900px;
}
.compose.is-drag { outline: 2px dashed var(--accent); outline-offset: -6px; }

.compose-head {
  display: flex; align-items: center; gap: 6px; flex: none;
  height: 40px; padding: 0 6px 0 14px;
  background: var(--bg); color: var(--text);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  cursor: pointer;
}
.compose-head b { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-head .icon-btn { width: 28px; height: 28px; }
.compose-head .icon-btn svg { width: 15px; height: 15px; }

.compose-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 0; }

.addr-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.addr-row > label { flex: none; width: 34px; padding-top: 4px; font-size: 12px; font-weight: 600; color: var(--text-4); }
.addr-field { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.addr-field input {
  flex: 1; min-width: 130px; border: 0; background: none; outline: none;
  height: 26px; font-size: 13.5px; color: var(--text);
}
.addr-toggles { display: flex; gap: 8px; flex: none; padding-top: 4px; }
.addr-toggles button { font-size: 12px; font-weight: 600; color: var(--text-4); }
.addr-toggles button:hover { color: var(--text); }

.addr-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 4px 0 4px; border-radius: var(--r-pill);
  background: var(--hover); font-size: 12.5px; max-width: 100%;
}
.addr-chip .avatar { width: 18px; height: 18px; font-size: 9px; }
.addr-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 2px; }
.addr-chip button { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--text-3); }
.addr-chip button:hover { background: var(--card); color: var(--text); }
.addr-chip.is-bad { background: var(--danger-soft); color: var(--danger); }

.autocomplete {
  position: absolute; top: 100%; left: 34px; right: 0; z-index: 20;
  background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); padding: 5px; max-height: 240px; overflow: auto;
}
.ac-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px; border-radius: var(--r-sm); text-align: left; }
.ac-item:hover, .ac-item.is-cursor { background: var(--hover); }
.ac-item .n { min-width: 0; }
.ac-item .n b { display: block; font-size: 13px; font-weight: 600; }
.ac-item .n span { display: block; font-size: 11.5px; color: var(--text-4); }

.compose-subject {
  width: 100%; border: 0; background: none; outline: none;
  padding: 9px 0; font-size: 14px; font-weight: 600;
  border-bottom: 1px solid var(--line-soft);
}
.compose-subject::placeholder { color: var(--text-4); font-weight: 500; }

.editor-toolbar {
  display: flex; align-items: center; gap: 1px; flex-wrap: wrap;
  padding: 6px 0; position: sticky; top: 0; background: var(--card); z-index: 2;
}
.editor-toolbar .icon-btn { width: 30px; height: 30px; }
.editor-toolbar .icon-btn svg { width: 16px; height: 16px; }
.editor-toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 5px; }

.editor {
  min-height: 180px; padding: 4px 0 12px; outline: none;
  font-size: 14px; line-height: 1.55; overflow-wrap: anywhere;
}
.editor:empty::before { content: attr(data-placeholder); color: var(--text-4); }
.editor p { margin: 0 0 10px; }
.editor blockquote {
  margin: 10px 0; padding-left: 12px;
  border-left: 2px solid var(--line); color: var(--text-3);
}
.editor a { color: var(--accent); text-decoration: underline; }
.editor ul, .editor ol { margin: 0 0 10px; padding-left: 22px; }
.editor ul { list-style: disc; } .editor ol { list-style: decimal; }
.editor img { max-width: 100%; border-radius: 6px; }
.editor .sig { color: var(--text-3); }

.compose-atts { display: grid; gap: 6px; padding: 4px 0 12px; }
.att-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r);
  background: var(--bg); border: 1px solid var(--line); font-size: 12.5px;
}
.att-row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-row .s { color: var(--text-4); font-size: 11.5px; flex: none; }
.att-row .prog { width: 70px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; flex: none; }
.att-row .prog i { display: block; height: 100%; background: var(--accent); transition: width .2s ease; }
.att-row.is-error { border-color: var(--danger); color: var(--danger); }

.compose-foot {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 10px 14px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line);
}
.compose-foot .saved { font-size: 11.5px; color: var(--text-4); margin-left: 4px; }
.compose-foot .spacer { flex: 1; }
.send-btn { padding-right: 8px; }
.send-split { display: inline-flex; }

@media (max-width: 719px) {
  .dock { right: 0; left: 0; }
  /* A full-screen composer owns the screen: the bottom bar underneath it
     would otherwise sit on top of the send button. */
  body.composing .bottombar { display: none; }
  .compose, .compose.is-full {
    /* inset alone sizes it: a height next to it fights the safe-area
       padding and pushes the send row off the bottom. */
    position: fixed; inset: 0; width: 100%; max-width: none; height: auto; max-height: none;
    border-radius: 0; border: 0;
    padding-top: var(--safe-t);
  }
  .compose.is-min { position: static; inset: auto; height: auto; width: 100%; border-radius: 0; padding-top: 0; }
  .dock { flex-direction: column; }
}
