#chat-conversation #chat-form {
  flex: none;
}

#chat-conversation #chat-form #chat-text {
  max-height: none;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y pinch-zoom;
}

#chat-conversation #chat-attachment-preview {
  max-height: 7rem;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.chat-panel :is(.chat-avatar, .desktop-avatar, .chat-message-avatar),
.chat-panel #chat-new {
  border-radius: 50%;
}

#chat-conversation #chat-form #chat-attach {
  color: #699780;
}

#chat-conversation #chat-form #chat-attach:is(:hover, [aria-expanded='true']):not(:disabled) {
  color: #1d5e4d;
}

@media (max-width: 799px) {
  #chat-history #chat-messages {
    height: max(48px, calc(clamp(220px, 48dvh, 650px) - var(--chat-composer-growth, 0px)));
    min-height: 0;
  }
}

@media (max-width: 650px) {
  #chat-history #chat-messages {
    height: max(48px, calc(clamp(160px, 42dvh, 420px) - var(--chat-composer-growth, 0px)));
  }
}

@media (min-width: 800px) {
  #app > .chat-panel.chat-panel-desktop {
    padding: 0;
    overflow: hidden;
  }

  .chat-panel-desktop > .desktop-chat {
    margin: 0;
    border: 0;
  }

  .desktop-chat #chat-list {
    padding-inline: 0;
  }

  .desktop-chat #chat-list .chat-thread {
    padding-inline-start: 12px;
  }

  .desktop-chat #chat-status {
    margin: 0;
    padding: 6px 10px;
    background: #fff;
  }

  .desktop-chat #chat-status:empty {
    display: none;
  }

  .desktop-chat #chat-conversation #chat-form,
  .desktop-chat #chat-conversation #chat-form:has(> #chat-reply-bar:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-top: 1px solid #d5e0dc;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
  }

  .desktop-chat #chat-conversation #chat-form:focus-within {
    outline: none;
  }

  .desktop-chat .chat-compose-field {
    display: flex;
    align-items: flex-end;
    min-width: 0;
    padding-block: 4px;
  }

  .desktop-chat .chat-compose-field:focus-within {
    box-shadow: inset 0 0 0 1px #84aa98;
  }

  .desktop-chat #chat-form > :is(#chat-reply-bar, #chat-edit-bar) {
    margin: 5px 8px 0;
  }

  .desktop-chat #chat-form #chat-text {
    min-height: calc(var(--entry-field-height) - 9px);
    padding: 8px;
  }

  .desktop-chat #chat-conversation #chat-form #chat-attach {
    width: 40px;
    height: calc(var(--entry-field-height) - 9px);
  }

  .desktop-chat #chat-conversation #chat-form #chat-send {
    width: 40px;
    min-width: 40px;
    height: calc(var(--entry-field-height) - 9px);
    border: 0;
    background: transparent;
    color: #1a5949;
  }

  .desktop-chat #chat-conversation #chat-form #chat-send:disabled {
    color: #59776d;
    opacity: .65;
  }

  .desktop-chat #chat-conversation #chat-form #chat-send:hover:not(:disabled) {
    background: #dae9e1;
  }

  .desktop-chat #chat-form #chat-send svg {
    width: 24px;
    height: 24px;
  }

  .desktop-chat-heading #chat-settings-toggle {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-inline-start: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: #426d5d;
  }

  #chat-settings-toggle svg {
    width: 19px;
    height: 19px;
  }

  .desktop-chat-heading #chat-settings-toggle:is(:hover, [aria-expanded='true']) {
    background: #edf4ef;
    color: #205a47;
  }

  #chat-settings-toggle:focus-visible,
  #chat-settings :is(button, input):focus-visible {
    outline: 2px solid #357f68;
    outline-offset: -2px;
  }

  #chat-settings[popover] {
    position: fixed;
    inset: auto;
    width: min(13rem, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid #d1e0d7;
    background: #fff;
    color: #193f35;
  }

  #chat-settings[popover]:not(:popover-open) {
    display: none;
  }

  #chat-settings.chat-settings-controls:popover-open {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 7px;
  }

  #chat-settings #chat-push-status {
    grid-column: 1 / -1;
    padding: 3px 4px;
    color: #506d62;
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  #chat-settings #chat-push-status:empty {
    display: none;
  }

  #chat-settings.chat-settings-controls > :is(button, label):not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 38px;
    margin: 0;
    padding: 5px 7px;
    border: 1px solid #dbe8df;
    background: #f5faf6;
    color: #254c40;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    white-space: normal;
  }

  #chat-settings.chat-settings-controls > :is(button, label):hover {
    border-color: #aac9b5;
    background: #edf4ef;
  }

  #chat-settings .chat-enter-option input {
    flex: none;
    margin: 0;
  }

  #chat-attachment-picker[popover] {
    position: fixed;
    inset: auto;
    width: min(14rem, calc(100vw - 16px));
    margin: 0;
    padding: 5px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid #d1e0d7;
    background: #fff;
    color: #193f35;
  }

  #chat-attachment-picker[popover]:popover-open {
    display: grid;
    gap: 1px;
  }

  #chat-attachment-picker[popover] button {
    min-height: 39px;
    padding: 7px 10px;
    border: 0;
    background: transparent;
    font-weight: 550;
    text-align: start;
  }

  #chat-attachment-picker[popover] button:is(:hover, :focus-visible) {
    background: #edf4ef;
  }

  #chat-attachment-picker[popover] button:focus-visible {
    outline: 2px solid #357f68;
    outline-offset: -2px;
  }

  #chat-attachment-picker .chat-attachment-limits {
    padding: 7px 10px 4px;
    border-top: 1px solid #e1ebe4;
    color: #506d62;
    font-size: 12px;
  }
}

@media (max-width: 799px) {
  #chat-conversation #chat-form {
    min-height: var(--entry-field-height);
  }

  #chat-conversation #chat-form:not(.editing) {
    padding-block: 2px;
  }

  #chat-conversation #chat-form #chat-attach {
    height: calc(var(--entry-field-height) - 6px);
  }

  #chat-conversation #chat-form:not(.editing) #chat-text {
    min-height: calc(var(--entry-field-height) - 6px);
  }

  #chat-conversation #chat-form #chat-send {
    width: 40px;
    min-width: 40px;
    height: 40px;
    margin-bottom: 0;
    background: transparent;
    color: #1a5949;
  }

  #chat-conversation #chat-form #chat-send:disabled {
    color: #59776d;
    opacity: .65;
  }

  #chat-conversation #chat-form #chat-send:hover:not(:disabled) {
    background: #dae9e1;
  }
}
