#replyBox, .cs-ft #csInput, .widget .wf #wInput {
  box-sizing: border-box;
  display: block;
  field-sizing: fixed;
  min-width: 0;
  width: 100%;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
}

#replyBox {
  min-height: 40px;
  padding-block: 9px;
  line-height: 20px;
  max-height: max(106px, min(480px, 51vh));
  max-height: max(106px, min(480px, 51dvh, calc(100dvh - 312px)));
  transition: border-color .18s, box-shadow .18s;
}

@media (max-width: 900px) {
  #replyBox { font-size: 16px; }
}

.cs-panel { height: calc(548px + var(--chat-draft-growth, 0px)); }
.cs-body { min-height: 0; }
.cs-hd, .cs-actions, .cs-meta { flex-shrink: 0; }
.cs-ft, .widget .wf {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px 8px;
  align-items: center;
}
.widget .wf { grid-template-columns: minmax(0, 1fr) auto; }
.cs-ft #csInput, .widget .wf #wInput {
  grid-area: 1 / 1 / 2 / -1;
  max-height: max(98px, min(480px, 52vh));
  max-height: max(98px, min(480px, 52dvh, calc(100dvh - 319px)));
}
.cs-ft #csFile { grid-area: 2 / 2; }
.cs-ft #csSend { grid-area: 2 / 3; }
.widget .wf > button:not(.chat-draft-expand) { grid-area: 2 / 2; }
.cs-ft .chat-draft-expand, .widget .wf .chat-draft-expand { grid-area: 2 / 1; justify-self: start; }

button.chat-draft-expand, .cs-ft button.chat-draft-expand {
  box-sizing: border-box;
  border: 1px solid #c7d7e3;
  border-radius: 8px;
  background: #f4f8fb;
  color: #123750;
  font: inherit;
  font-size: 12px;
  min-height: 34px;
  max-width: 100%;
  padding: 4px 8px;
  cursor: pointer;
}
.chat-draft-expand[hidden] { display: none !important; }
.chat-draft-expand:focus-visible, .chat-draft-dialog :focus-visible {
  outline: 2px solid #147a9d;
  outline-offset: 2px;
}

.chat-draft-dialog {
  box-sizing: border-box;
  position: fixed;
  inset: var(--chat-editor-center, 50%) 0 auto;
  transform: translateY(-50%);
  width: min(640px, calc(100vw - 24px));
  height: min(700px, calc(var(--chat-editor-viewport, 100dvh) - 24px));
  max-height: none;
  max-width: none;
  margin: 0 auto;
  padding: 0;
  border: 1px solid #c7d7e3;
  border-radius: 16px;
  color: #102e46;
  background: #fff;
  box-shadow: 0 16px 48px #0e253c33;
  font: inherit;
  overflow: hidden;
}
.chat-draft-dialog[open] { display: flex; flex-direction: column; }
.chat-draft-dialog::backdrop { background: #102c4666; }
.chat-draft-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #d9e4ec;
}
.chat-draft-dialog button {
  background: #10354e;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 15px;
  font: inherit;
  cursor: pointer;
}
.chat-draft-dialog textarea {
  box-sizing: border-box;
  flex: 1 1 0;
  min-height: 0;
  width: calc(100% - 28px);
  margin: 10px 14px 14px;
  padding: 10px 12px;
  border: 1px solid #c7d7e3;
  border-radius: 8px;
  background: #f9fcfe;
  color: inherit;
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
}
