.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-start-form {
  display: inline-flex;
}

.chat-start-form .button {
  width: 100%;
}

.chat-unavailable {
  align-items: flex-start;
  color: #64748b;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-unavailable__button {
  opacity: 0.68;
  pointer-events: none;
}

.chat-unavailable small {
  font-size: 12px;
  line-height: 1.45;
  max-width: 240px;
}

.application-chat-row__actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
}

.conversation-item {
  align-items: stretch;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 18px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 18px;
  transition: var(--transition);
}

.conversation-item:hover,
.conversation-item:focus-visible {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(14, 141, 219, 0.12);
  outline: none;
}

.conversation-item--unread {
  background: #f8fbff;
  border-color: #bfdbfe;
}

.conversation-item--unread .conversation-item__main strong,
.conversation-item--unread .conversation-item__main p {
  font-weight: 800;
}

.conversation-item__main {
  min-width: 0;
}

.conversation-item__title-row {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.conversation-item__title-row strong {
  color: var(--color-text);
  font-size: 18px;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item__title-row time,
.conversation-item__context,
.conversation-item__main p,
.conversation-item__footer {
  color: #64748b;
  line-height: 1.5;
}

.conversation-item__title-row time {
  flex: 0 0 auto;
  font-size: 13px;
  white-space: nowrap;
}

.conversation-item__context {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item__main p {
  margin: 8px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item__footer {
  align-items: center;
  display: flex;
  justify-content: flex-end;
  white-space: nowrap;
}

.conversation-item__badge {
  align-items: center;
  background: var(--color-primary);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: center;
  min-height: 24px;
  min-width: 24px;
  padding: 0 8px;
}

.chat-presence {
  align-items: center;
  color: #64748b;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
  line-height: 1.4;
}

.chat-presence__dot {
  background: #cbd5e1;
  border-radius: 999px;
  display: inline-flex;
  height: 8px;
  width: 8px;
}

.chat-presence.is-online {
  color: #16a34a;
}

.chat-presence.is-offline {
  color: #64748b;
}

.chat-presence.is-online .chat-presence__dot {
  background: #22c55e;
}

.chat-panel {
  background: var(--color-surface);
  border: 1px solid #eef2f7;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 180px);
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  align-items: flex-start;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 24px;
}

.chat-header__main {
  min-width: 0;
}

.chat-header h1 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.chat-header a:hover,
.chat-header a:focus-visible {
  color: var(--color-primary);
  outline: none;
  text-decoration: underline;
}

.chat-header p {
  color: #64748b;
  line-height: 1.5;
  margin: 0 0 8px;
}

.chat-connection-status {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  color: #64748b;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
}

.chat-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  position: relative;
}

.chat-message {
  display: flex;
  justify-content: flex-start;
}

.chat-message--own {
  justify-content: flex-end;
}

.chat-message__bubble {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 18px 18px 18px 6px;
  max-width: min(72%, 680px);
  padding: 12px 14px;
}

.chat-message--own .chat-message__bubble {
  background: #eff6ff;
  border-color: #bfdbfe;
  border-radius: 18px 18px 6px 18px;
}

.chat-message__bubble p {
  color: var(--color-text);
  line-height: 1.6;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-message__bubble time {
  color: #64748b;
  display: block;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
  text-align: right;
}

.chat-load-more,
.chat-empty,
.chat-new-messages {
  align-self: center;
  color: #64748b;
}

.chat-load-more,
.chat-new-messages {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  padding: 9px 14px;
  transition: var(--transition);
}

.chat-load-more:hover,
.chat-load-more:focus-visible,
.chat-new-messages:hover,
.chat-new-messages:focus-visible {
  color: var(--color-primary);
  border-color: var(--color-primary);
  outline: none;
}

.chat-new-messages {
  bottom: 18px;
  box-shadow: var(--shadow);
  position: sticky;
  z-index: 2;
}

.chat-composer {
  align-items: flex-end;
  border-top: 1px solid #eef2f7;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 20px 24px 24px;
}

.chat-composer__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-composer__field label {
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.chat-composer textarea {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  font: inherit;
  min-height: 74px;
  outline: none;
  padding: 14px 16px;
  resize: vertical;
  transition: var(--transition);
  width: 100%;
}

.chat-composer textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(14, 141, 219, 0.12);
}

.chat-composer__field.has-error textarea {
  border-color: #dc2626;
}

.chat-composer .button {
  min-height: 48px;
  padding-inline: 22px;
}

@media (max-width: 720px) {
  .application-chat-row {
    align-items: stretch;
    flex-direction: column;
  }

  .application-chat-row__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-unavailable {
    align-items: stretch;
  }

  .chat-unavailable small {
    max-width: none;
  }

  .conversation-item {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .conversation-item__footer {
    justify-content: flex-start;
    width: 100%;
  }

  .conversation-item__title-row {
    flex-direction: column;
    gap: 4px;
  }

  .chat-message__bubble {
    max-width: 86%;
  }

  .chat-composer {
    grid-template-columns: 1fr;
  }

  .chat-composer .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .chat-panel {
    border-radius: 18px;
  }

  .chat-header,
  .chat-messages,
  .chat-composer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .chat-header h1 {
    font-size: 24px;
  }

  .chat-message__bubble {
    max-width: 92%;
  }
}
