.portal-chat-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
}

.portal-chat-toggle {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem 0.4rem 0.6rem;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  cursor: pointer;
}

.portal-chat-toggle__lamp {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #9ca3af;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.28);
}

.portal-chat-toggle__lamp.is-online {
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.24), 0 0 10px rgba(22, 163, 74, 0.45);
}

.portal-chat-toggle__lamp.is-unread-blink {
  animation: portal-chat-lamp-blink 1.8s ease-in-out infinite;
}

@keyframes portal-chat-lamp-blink {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.86);
  }
}

.portal-chat-toggle__label {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
}

.portal-chat-toggle__count {
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: rgba(15, 23, 42, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.portal-chat-mini-users {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 200px;
  overflow: hidden;
}

.portal-chat-mini-user {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  padding: 0.16rem 0.48rem;
  font-size: 0.72rem;
  line-height: 1;
  color: rgba(15, 23, 42, 0.8);
  white-space: nowrap;
}

.portal-chat-mini-user__lamp {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #16a34a;
}

.portal-chat-panel[hidden] {
  display: none !important;
}

.portal-chat-panel {
  --portal-chat-top: clamp(58px, 8vh, 96px);
  position: fixed !important;
  top: var(--portal-chat-top);
  right: clamp(12px, 2vw, 28px);
  left: auto;
  width: min(980px, calc(100vw - 24px));
  height: min(86dvh, 860px);
  min-width: min(560px, calc(100vw - 24px));
  min-height: min(420px, calc(100dvh - var(--portal-chat-top) - max(8px, env(safe-area-inset-bottom, 0px))));
  max-height: calc(100dvh - var(--portal-chat-top) - max(8px, env(safe-area-inset-bottom, 0px)));
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 22px 42px rgba(15, 23, 42, 0.24);
  padding: 0.85rem 0.85rem max(1rem, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
  resize: both;
  z-index: 21000 !important;
}

.portal-chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: move;
  user-select: none;
}

.portal-chat-panel__head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.portal-chat-panel__head-actions button {
  cursor: pointer;
}

.portal-chat-panel__head-actions [data-role="portal-chat-toggle-history"][aria-pressed="true"] {
  border-color: rgba(30, 64, 175, 0.35);
  background: rgba(224, 231, 255, 0.7);
  color: #1e3a8a;
}

.portal-chat-panel__head-actions [data-role="portal-chat-open-settings"].is-active {
  border-color: rgba(30, 64, 175, 0.35);
  background: rgba(224, 231, 255, 0.7);
  color: #1e3a8a;
}

.portal-chat-panel.is-dragging {
  transition: none !important;
}

.portal-chat-panel__main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 0;
}

.portal-chat-pref-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  background: #fff;
  padding: 0.3rem 0.55rem;
  font-size: 0.76rem;
  color: rgba(15, 23, 42, 0.82);
  user-select: none;
}

.portal-chat-pref-toggle input {
  width: 15px;
  height: 15px;
  accent-color: #0f172a;
}

.portal-chat-settings {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  padding: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
  overflow: auto;
}

.portal-chat-settings[hidden] {
  display: none !important;
}

.portal-chat-settings__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding-bottom: 0.48rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

.portal-chat-settings__body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.portal-chat-link-modal[hidden] {
  display: none !important;
}

.portal-chat-link-modal {
  position: absolute;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0.55rem;
}

.portal-chat-link-modal__dialog {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.portal-chat-link-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

.portal-chat-link-modal__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.portal-chat-link-modal__frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  flex: 1 1 auto;
  min-height: 0;
}

.portal-chat-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  max-width: 100%;
  min-width: 0;
}

.portal-chat-active-chip__lamp {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #16a34a;
  flex: 0 0 auto;
}

.portal-chat-active-chip > span:last-child {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-chat-panel__create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.6rem;
}

.portal-chat-panel.is-inquiry-context .portal-chat-panel__create {
  grid-template-columns: 1fr;
}

.portal-chat-collapse {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  overflow: hidden;
}

.portal-chat-collapse__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.74rem;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.76);
}

.portal-chat-collapse__summary::-webkit-details-marker {
  display: none;
}

.portal-chat-collapse__summary::after {
  content: "▾";
  font-size: 0.78rem;
  color: rgba(15, 23, 42, 0.72);
  transition: transform 0.18s ease;
}

.portal-chat-collapse:not([open]) .portal-chat-collapse__summary::after {
  transform: rotate(-90deg);
}

.portal-chat-collapse > .portal-chat-form {
  border: none;
  border-top: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 0;
  background: transparent;
  padding: 0.5rem 0.6rem 0.6rem;
}

.portal-chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.86);
}

.portal-chat-form[hidden] {
  display: none !important;
}

.portal-chat-form label {
  font-size: 0.74rem;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.72);
}

.portal-chat-form__hint {
  font-size: 0.72rem;
  color: rgba(15, 23, 42, 0.62);
}

.portal-chat-form input,
.portal-chat-form select {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.2);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 0.85rem;
  padding: 0.42rem 0.55rem;
}

.portal-chat-form__row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.portal-chat-form__row select {
  flex: 1 1 auto;
}

.portal-chat-panel__layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 0.7rem;
  align-items: stretch;
  min-height: 0;
  flex: 1 1 auto;
}

.portal-chat-conversation-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 0.45rem;
}

.portal-chat-conversation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.portal-chat-pref-toggle--compact {
  padding: 0.24rem 0.45rem;
  font-size: 0.72rem;
}

.portal-chat-pref-toggle--compact span {
  white-space: nowrap;
}

.portal-chat-conversation-list {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  overflow: auto;
  max-height: none;
  min-height: clamp(180px, 24vh, 320px);
  height: 100%;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.portal-chat-conversation-list.is-table-view {
  padding: 0;
  gap: 0;
}

.portal-chat-conversation-card {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.portal-chat-conversation-card.is-pinned {
  border-color: rgba(30, 64, 175, 0.42);
  background: rgba(238, 242, 255, 0.7);
}

.portal-chat-conversation-card.has-unread {
  border-color: rgba(22, 163, 74, 0.46);
  background: rgba(240, 253, 244, 0.9);
}

.portal-chat-conversation-card.has-unread .portal-chat-conversation {
  border-color: rgba(22, 163, 74, 0.52);
}

.portal-chat-conversation-pin {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  font-size: 0.68rem;
  color: rgba(15, 23, 42, 0.72);
  user-select: none;
}

.portal-chat-conversation-pin input {
  width: 14px;
  height: 14px;
  accent-color: #1d4ed8;
}

.portal-chat-conversation-pin.is-compact {
  justify-content: center;
}

.portal-chat-conversation {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
  padding: 0.48rem 0.58rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 0 0 auto;
  min-height: 2.75rem;
  overflow: hidden;
}

.portal-chat-conversation:hover {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.24);
}

.portal-chat-conversation.is-active {
  background: #eef2ff;
  border-color: rgba(30, 64, 175, 0.4);
  color: #0f172a;
}

.portal-chat-conversation.is-online:not(.is-active) {
  border-color: rgba(22, 163, 74, 0.45);
  background: rgba(240, 253, 244, 0.96);
}

.portal-chat-conversation.is-online:not(.is-active):hover {
  border-color: rgba(21, 128, 61, 0.56);
  background: rgba(220, 252, 231, 0.92);
}

.portal-chat-conversation.is-inquiry:not(.is-active) {
  border-color: rgba(37, 99, 235, 0.34);
  background: rgba(239, 246, 255, 0.96);
}

.portal-chat-conversation.is-inquiry:not(.is-active):hover {
  border-color: rgba(30, 64, 175, 0.52);
  background: rgba(219, 234, 254, 0.98);
}

.portal-chat-conversation.has-unread:not(.is-active) {
  border-color: rgba(22, 163, 74, 0.52);
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.2);
}

.portal-chat-conversation--direct-start {
  border-style: dashed;
}

.portal-chat-conversation--direct-start .portal-chat-conversation__preview {
  color: rgba(21, 128, 61, 0.9);
}

.portal-chat-conversation__title {
  font-weight: 700;
  font-size: 0.82rem;
  color: rgba(15, 23, 42, 0.92);
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-conversation__meta {
  font-size: 0.69rem;
  color: rgba(15, 23, 42, 0.72);
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-conversation__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.portal-chat-conversation__badge {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(21, 128, 61, 0.45);
  background: rgba(240, 253, 244, 0.95);
  color: #166534;
  font-size: 0.64rem;
  line-height: 1;
  font-weight: 700;
  padding: 0.16rem 0.34rem;
}

.portal-chat-conversation__preview {
  font-size: 0.74rem;
  opacity: 0.82;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.26;
  max-height: 2.52em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-conversation__links {
  margin-top: 0.14rem;
}

.portal-chat-conversation__inquiry-link {
  font-size: 0.7rem;
  color: #1d4ed8;
  text-decoration: none;
}

.portal-chat-conversation__inquiry-link:hover {
  text-decoration: underline;
}

.portal-chat-conversation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
  color: rgba(15, 23, 42, 0.88);
}

.portal-chat-conversation-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(226, 232, 240, 0.92);
  border-bottom: 1px solid rgba(15, 23, 42, 0.18);
  text-align: left;
  font-size: 0.67rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.68);
  padding: 0.34rem 0.38rem;
}

.portal-chat-conversation-table td {
  padding: 0.32rem 0.4rem;
  vertical-align: top;
}

.portal-chat-conversation-table__summary-row > td {
  border-bottom: none;
  padding-top: 0.34rem;
  padding-bottom: 0.06rem;
  font-size: 0.69rem;
  color: rgba(15, 23, 42, 0.64);
}

.portal-chat-conversation-table__title-row > td {
  border-bottom: none;
  padding-top: 0.04rem;
  padding-bottom: 0.08rem;
}

.portal-chat-conversation-table__details-row > td {
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  padding-top: 0;
  padding-bottom: 0.46rem;
}

.portal-chat-conversation-table__details-row:last-child > td {
  border-bottom: none;
}

.portal-chat-conversation-table tr.is-active td {
  background: rgba(224, 231, 255, 0.68);
}

.portal-chat-conversation-table tr.has-unread td {
  background: rgba(240, 253, 244, 0.82);
}

.portal-chat-conversation-table tr.is-pinned td {
  box-shadow: none;
}

.portal-chat-conversation-table__summary-row.is-pinned > td,
.portal-chat-conversation-table__title-row.is-pinned > td,
.portal-chat-conversation-table__details-row.is-pinned > td {
  box-shadow: inset 2px 0 0 rgba(37, 99, 235, 0.48);
}

.portal-chat-conversation-table__pin {
  width: 2.1rem;
  text-align: center;
  vertical-align: middle;
}

.portal-chat-conversation-table__row-clickable {
  cursor: pointer;
}

.portal-chat-conversation-table tbody .portal-chat-conversation-table__row-clickable:hover td {
  background: rgba(241, 245, 249, 0.88);
}

.portal-chat-conversation-table__pin input {
  width: 14px;
  height: 14px;
  accent-color: #1d4ed8;
}

.portal-chat-conversation-table__title-cell,
.portal-chat-conversation-table__details-cell {
  text-transform: none;
  letter-spacing: normal;
}

.portal-chat-conversation-table__title {
  font-weight: 700;
  font-size: 0.89rem;
  color: #0f172a;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-conversation-table__links {
  margin-top: 0.14rem;
}

.portal-chat-conversation-table__links .portal-chat-conversation__inquiry-link {
  font-size: 0.72rem;
}

.portal-chat-conversation-table__details {
  font-size: 0.74rem;
  color: rgba(15, 23, 42, 0.68);
  line-height: 1.28;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-height: 2.58em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-conversation-starts {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.portal-chat-conversation-starts__label {
  font-size: 0.66rem;
  color: rgba(15, 23, 42, 0.62);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0 0.2rem;
}

.portal-chat-messages-pane {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.portal-chat-form--members {
  flex: 0 0 auto;
}

.portal-chat-member-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.portal-chat-member-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  font-size: 0.72rem;
  color: rgba(15, 23, 42, 0.8);
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-chat-messages {
  flex: 1 1 auto;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: #fff;
  padding: 0.6rem;
  overflow: auto;
  max-height: none;
  min-height: 0;
}

.portal-chat-message {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.45rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.portal-chat-message.is-ai {
  border-color: rgba(30, 64, 175, 0.3);
  background: rgba(238, 242, 255, 0.72);
}

.portal-chat-message:last-child {
  margin-bottom: 0;
}

.portal-chat-message__meta {
  font-size: 0.7rem;
  color: rgba(15, 23, 42, 0.68);
  margin-bottom: 0.2rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-message__body {
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.portal-chat-message__body a {
  color: #1f4fbf;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.portal-chat-message__body a:hover {
  color: #1d3f98;
}

.portal-chat-proposal {
  margin-top: 0.4rem;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 10px;
  background: #fff;
  padding: 0.42rem 0.52rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.portal-chat-proposal__head {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.84);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-proposal__summary,
.portal-chat-proposal__details {
  font-size: 0.74rem;
  color: rgba(15, 23, 42, 0.8);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-proposal__details {
  color: rgba(15, 23, 42, 0.66);
}

.portal-chat-proposal__links {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}

.portal-chat-proposal__link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
}

.portal-chat-proposal__link-row a {
  color: #1f4fbf;
  text-decoration: none;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-proposal__link-row a:hover {
  text-decoration: underline;
}

.portal-chat-proposal__link-meta {
  font-size: 0.68rem;
  color: rgba(15, 23, 42, 0.6);
}

.portal-chat-proposal__link-row .btn {
  min-height: 28px;
  padding: 0.24rem 0.55rem;
  font-size: 0.69rem;
}

.portal-chat-proposal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
  margin-top: 0.1rem;
}

.portal-chat-proposal__actions .btn {
  min-height: 34px;
}

.portal-chat-message__media-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.portal-chat-message__image {
  display: block;
  max-width: min(100%, 360px);
  max-height: 220px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  object-fit: contain;
}

.portal-chat-message__audio {
  width: min(100%, 360px);
}

.portal-chat-message__audio-download {
  margin-top: -0.15rem;
  width: fit-content;
}

.portal-chat-message__file {
  color: #1d4ed8;
  text-decoration: underline;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-send {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.48rem;
  padding-bottom: 0.15rem;
  min-width: 0;
}

.portal-chat-send__message-row {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  width: 100%;
  min-width: 0;
}

.portal-chat-send__message-row input[type="text"] {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 0.86rem;
  padding: 0.45rem 0.55rem;
}

.portal-chat-send__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 40px;
  min-width: 40px;
  cursor: pointer;
  min-height: 40px;
  height: 40px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 10px;
  background: #fff;
  color: rgba(15, 23, 42, 0.82);
  padding: 0;
  flex: 0 0 40px;
}

.portal-chat-send__icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.portal-chat-send__icon-btn:hover {
  border-color: rgba(15, 23, 42, 0.32);
  background: rgba(148, 163, 184, 0.08);
}

.portal-chat-send__icon-btn:focus-visible {
  outline: 2px solid rgba(29, 78, 216, 0.36);
  outline-offset: 2px;
}

.portal-chat-send__icon-btn.is-recording {
  border-color: rgba(185, 28, 28, 0.42);
  background: rgba(254, 226, 226, 0.78);
  color: #b91c1c;
}

.portal-chat-send__media-btn input {
  display: none;
}

.portal-chat-send__controls-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  min-width: 0;
}

.portal-chat-send .portal-chat-send__submit-btn {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
}

.portal-chat-send__submit-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.portal-chat-send__options {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.08rem;
  scrollbar-width: thin;
}

.portal-chat-send__options > * {
  flex: 0 0 auto;
}

.portal-chat-send .btn {
  min-height: 40px;
}

.portal-chat-send__mail-btn {
  border-radius: 999px;
  white-space: nowrap;
}

.portal-chat-send__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 999px;
  background: #fff;
  padding: 0.28rem 0.62rem;
  min-height: 36px;
  font-size: 0.74rem;
  color: rgba(15, 23, 42, 0.78);
  white-space: nowrap;
  user-select: none;
}

.portal-chat-send__toggle input {
  width: 14px;
  height: 14px;
  accent-color: #0f172a;
}

.portal-chat-send__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.portal-chat-send__audio-preview {
  width: min(100%, 360px);
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 10px;
  background: #fff;
}

.portal-chat-send__audio-preview[hidden] {
  display: none !important;
}

.portal-chat-send-meta {
  min-height: 1rem;
  font-size: 0.72rem;
  color: rgba(15, 23, 42, 0.68);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-send-meta.is-error {
  color: #b91c1c;
}

.portal-chat-email-ping-info {
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.04);
  color: rgba(15, 23, 42, 0.82);
  font-size: 0.74rem;
  line-height: 1.32;
  padding: 0.38rem 0.55rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-email-ping-info[hidden] {
  display: none !important;
}

.portal-chat-email-ping-info.is-error {
  border-color: rgba(185, 28, 28, 0.38);
  background: rgba(254, 226, 226, 0.7);
  color: #991b1b;
}

.portal-chat-email-ping-info.is-muted {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(148, 163, 184, 0.12);
  color: rgba(15, 23, 42, 0.66);
}

.portal-chat-panel__status {
  min-height: 1.1rem;
  font-size: 0.76rem;
  color: rgba(15, 23, 42, 0.7);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.portal-chat-panel__status.is-error {
  color: #b91c1c;
}

.portal-chat-empty {
  padding: 0.55rem;
  font-size: 0.78rem;
  color: rgba(15, 23, 42, 0.66);
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 1024px) {
  .portal-chat-mini-users {
    display: inline-flex;
    max-width: 150px;
  }

  .portal-chat-panel {
    --portal-chat-top: max(56px, env(safe-area-inset-top, 0px) + 6px);
    left: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    min-height: 0;
    top: var(--portal-chat-top);
    height: min(88dvh, 860px);
    max-height: calc(100dvh - var(--portal-chat-top) - max(8px, env(safe-area-inset-bottom, 0px)));
    resize: none;
  }

  .portal-chat-panel__create {
    grid-template-columns: 1fr;
  }

  .portal-chat-panel__layout {
    grid-template-columns: 1fr;
  }

  .portal-chat-conversation-list,
  .portal-chat-messages {
    max-height: none;
    min-height: 0;
  }

  .portal-chat-send__controls-row {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .portal-chat-mini-users {
    display: none;
  }

  .portal-chat-toggle__label {
    display: none;
  }

  .portal-chat-toggle {
    padding-right: 0.5rem;
  }

  .portal-chat-panel {
    --portal-chat-top: max(52px, env(safe-area-inset-top, 0px) + 4px);
    left: max(4px, env(safe-area-inset-left, 0px));
    right: max(4px, env(safe-area-inset-right, 0px));
    top: var(--portal-chat-top);
    min-width: 0;
    min-height: 0;
    height: calc(100dvh - var(--portal-chat-top) - max(2px, env(safe-area-inset-bottom, 0px)));
    max-height: calc(100dvh - var(--portal-chat-top) - max(2px, env(safe-area-inset-bottom, 0px)));
    padding: 0.65rem 0.65rem max(0.85rem, env(safe-area-inset-bottom, 0px));
    border-radius: 12px;
    resize: none;
  }

  .portal-chat-panel__head {
    flex-wrap: wrap;
  }

  .portal-chat-panel__head-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .portal-chat-conversation-list {
    max-height: 180px;
  }

  .portal-chat-send__icon-btn,
  .portal-chat-send .portal-chat-send__submit-btn {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .portal-chat-send__controls-row {
    gap: 0.35rem;
  }

  .portal-chat-send__options {
    gap: 0.35rem;
  }

  .portal-chat-send__mail-btn {
    font-size: 0.74rem;
    padding: 0.34rem 0.62rem;
  }

  .portal-chat-send__toggle {
    min-height: 34px;
    font-size: 0.7rem;
    padding: 0.24rem 0.54rem;
  }
}
