.composer.chat-composer {
  display: block;
  position: relative;
  min-width: 0;
  flex: none;
  padding: 8px 10px calc(9px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.chat-composer [hidden] { display: none !important; }
.chat-compose-row { display: flex; align-items: flex-end; gap: 5px; }
.chat-compose-row > button, .chat-compose-recording > button { flex: 0 0 auto; }
.chat-compose-icon, .chat-compose-remove {
  display: grid;
  place-items: center;
  width: 40px;
  height: 42px;
  border-radius: 12px;
  color: var(--ink-2);
  transition: background .16s, color .16s;
}
.chat-compose-icon svg, .chat-compose-attach svg, .chat-compose-drop svg { width: 21px; height: 21px; }
.chat-compose-icon[aria-expanded="true"] { background: var(--brand-soft); color: var(--brand); }
.chat-compose-icon:disabled, .chat-compose-remove:disabled { opacity: .46; cursor: default; }
.chat-compose-icon[data-compose="send"] { background: var(--brand); color: #fff; }
.chat-compose-icon[data-compose="send"]:disabled { background: var(--surface-3); color: var(--ink-2); opacity: .65; }
.chat-compose-input-area {
  flex: 1 1 100%;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.chat-compose-input-area:focus-within { border-color: var(--brand); }
.chat-composer #chatInput {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  max-height: 116px;
  border: 0;
  outline: 0;
  border-radius: 13px;
  resize: none;
  padding: 9px 5px 9px 10px;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  scrollbar-width: thin;
}
.chat-composer #chatInput:focus-visible { outline: none; }
.chat-composer #chatInput::placeholder { color: var(--ink-3); }
.chat-compose-input-area .chat-compose-icon { flex: none; width: 38px; height: 40px; }
.chat-composer :is(button, a):focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.chat-compose-panel {
  position: absolute;
  z-index: 8;
  inset-inline-start: 10px;
  bottom: calc(100% + 6px);
  max-width: calc(100% - 20px);
  max-height: var(--chat-compose-room, 290px);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--sh-3);
}
.chat-compose-emotes {
  width: 318px;
  max-height: min(290px, 42vh, var(--chat-compose-room, 290px));
  max-height: min(290px, 42dvh, var(--chat-compose-room, 290px));
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.chat-compose-panel-tabs { display: flex; padding: 0 2px 6px; gap: 4px; }
.chat-compose-panel-tabs button {
  flex: 1;
  min-height: 34px;
  font-size: 13px;
  font-weight: 650;
  border-radius: 8px;
  color: var(--ink-2);
}
.chat-compose-panel-tabs button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); }
.chat-compose-emoji-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.chat-compose-sticker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.chat-compose-emoji-grid button, .chat-compose-sticker {
  display: grid;
  place-items: center;
  min-height: 41px;
  border-radius: 9px;
  font-size: 22px;
}
.chat-compose-sticker { min-height: 61px; }
.chat-compose-sticker img { width: 46px; height: 46px; object-fit: contain; }
.chat-compose-credit { color: var(--ink-2); padding: 6px 5px 1px; font-size: 11px; }
.chat-compose-credit a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.chat-compose-attach { min-width: 172px; display: grid; gap: 2px; }
.chat-compose-attach button {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 9px;
  border-radius: 9px;
  font-size: 14px;
  text-align: left;
}
.chat-compose-attach svg { color: var(--brand); }

.chat-compose-previews {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 2px 2px 6px;
}
.chat-compose-preview {
  flex: 0 0 150px;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  padding: 5px 3px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.chat-compose-preview-media {
  width: 34px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  overflow: hidden;
  color: var(--brand);
  background: var(--brand-soft);
}
.chat-compose-preview-media svg, .chat-compose-remove svg { width: 16px; height: 16px; }
.chat-compose-preview-media :is(img, video) { width: 100%; height: 100%; object-fit: cover; }
.chat-compose-preview[data-kind="sticker"] img { object-fit: contain; }
.chat-compose-preview[data-kind="voice"] { flex-basis: min(245px, 100%); }
.chat-compose-preview[data-kind="voice"] .chat-compose-preview-label { display: none; }
.chat-compose-preview[data-kind="voice"] .chat-compose-preview-media { flex: 1; width: auto; min-width: 0; background: transparent; }
.chat-compose-preview-label { flex: 1 1 auto; min-width: 0; font-size: 12px; line-height: 1.25; }
.chat-compose-preview-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-compose-preview-label small { color: var(--ink-2); font-size: 11px; }
.chat-compose-remove { width: 29px; height: 34px; flex: none; }

.chat-compose-drop, .chat-compose-recording {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 45px;
  margin-bottom: 6px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
}
.chat-compose-drop { justify-content: center; border: 1px dashed var(--brand); background: var(--brand-soft); color: var(--brand); }
.chat-compose-recording .chat-compose-record-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: chat-compose-pulse 1.35s ease-in-out infinite; }
.chat-compose-record-label { flex: 1; min-width: 0; }
.chat-compose-duration { font-variant-numeric: tabular-nums; color: var(--ink); }
.chat-compose-recording .chat-compose-icon { height: 34px; width: 36px; }
.chat-compose-recording [data-compose="stop-record"] { color: var(--danger); }
.chat-compose-error, .chat-compose-progress { margin: 0 2px 5px; font-size: 12.5px; overflow-wrap: anywhere; }
.chat-compose-error { color: var(--danger); }
.chat-compose-progress { color: var(--ink-2); }

@keyframes chat-compose-pulse { 50% { opacity: .45; } }
@media (hover: hover) {
  .chat-compose-icon:not(:disabled, [data-compose="send"]):hover, .chat-compose-remove:not(:disabled):hover,
  .chat-compose-panel button:not([aria-pressed="true"]):hover { background: var(--surface-3); color: var(--ink); }
  .chat-compose-icon[data-compose="send"]:not(:disabled):hover { background: var(--brand-press); }
}
@media (min-width: 860px) {
  #device .composer.chat-composer { padding: 10px 16px 14px; }
  .chat-compose-row { gap: 8px; }
  .chat-compose-icon { width: 43px; }
  .chat-compose-panel { inset-inline-start: 16px; }
  .chat-composer #chatInput { padding-inline-start: 13px; }
}
@media (max-width: 359px) {
  .chat-compose-row { gap: 3px; }
  .chat-compose-row > .chat-compose-icon { width: 36px; }
  .chat-compose-input-area .chat-compose-icon { width: 34px; }
}
@media (prefers-reduced-motion: reduce) { .chat-compose-record-dot { animation: none !important; } }
