.compose-host {
  position: fixed;
  z-index: 40;
  right: 24px;
  bottom: 0;
}

.compose {
  display: flex;
  flex-direction: column;
  width: min(580px, calc(100vw - 48px));
  height: min(620px, calc(100dvh - var(--topbar-h) - 24px));
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.compose.is-expanded {
  position: fixed;
  inset: calc(var(--topbar-h) + 16px) max(24px, calc((100vw - 980px) / 2)) 24px;
  width: auto;
  height: auto;
  border-bottom: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
}

.compose.is-dropping {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--line);
}

.compose-title {
  font-size: var(--text-md);
  font-weight: 650;
}

.compose-window-actions {
  display: flex;
  gap: 2px;
}

.compose-window-actions .icon-button {
  width: 32px;
  height: 32px;
}

.compose-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 12px 0;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-sm);
}

.compose-error .icon {
  margin-top: 1px;
}

/* (drafts) Changed or ended elsewhere: load the latest version, or keep these changes as a new draft. */
.compose-draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 12px 0;
}

.compose-draft-actions[hidden] {
  display: none;
}

.compose-fields {
  padding: 0 16px;
}

.compose-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.compose-label {
  flex: 0 0 56px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.compose-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  outline: none;
}

.compose-field:focus-within {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

.compose-input[aria-invalid="true"] {
  color: var(--danger);
}

.compose-from {
  color: var(--fg);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-toggles {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  font-size: var(--text-sm);
}

.cc-toggles .link-button {
  color: var(--fg-muted);
}

.cc-toggles .link-button:hover {
  color: var(--accent-text);
}

.field-error {
  margin: 6px 0;
  color: var(--danger);
  font-size: var(--text-xs);
}

.compose-body {
  flex: 1 1 auto;
  min-height: 120px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  font-size: 14.5px;
  line-height: 1.55;
  resize: none;
  outline: none;
}

.compose-body:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus-ring);
}

.compose-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 128px;
  padding: 0 12px 8px;
  overflow-y: auto;
}

.compose-attachments .attachment {
  flex: 0 1 240px;
  min-width: 180px;
  padding: 4px 2px 4px 4px;
}

.compose-attachments .file-kind {
  width: 30px;
  height: 30px;
  font-size: 9px;
}

.compose-attachments .icon-button {
  width: 30px;
  height: 30px;
}

#compose-attachments-error {
  margin: 0 16px 8px;
}

.compose-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.send-button {
  min-width: 96px;
}

.compose-status {
  margin-left: 6px;
  color: var(--fg-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spacer {
  flex: 1 1 auto;
}

@media (max-width: 760px) {
  .compose-host {
    inset: 0;
  }

  .compose,
  .compose.is-expanded {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .compose-expand {
    display: none;
  }
}

/* A field the service decides (a reply's recipients and subject when Box
   composes replies): shown like From, never an input. */
.compose-field.is-fixed .compose-fixed {
  flex: 1 1 auto;
  min-width: 0;
}

.compose-field.is-fixed:focus-within {
  border-bottom-color: var(--line);
  box-shadow: none;
}

/* What the service adds to the message (a forward's forwarded message). */
.compose-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 10px 16px 0;
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.compose-note .icon {
  flex: none;
  width: 14px;
  height: 14px;
}
