.chat-mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(68px, 1fr));
  gap: 3px;
  width: fit-content;
  padding: 3px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
}

.composer-bottom .tool-row .chat-mode-switch {
  flex: 0 0 auto;
  align-self: center;
}

.chat-mode-availability {
  min-height: 18px;
  margin: 6px 0 0;
  color: #9a6700;
  font-size: 12px;
}

.chat-mode-availability.is-ready { color: #188251; }

.composer .chat-mode-switch button:not(.active) {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: #ffffff;
  color: #526174;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

.composer .chat-mode-switch button:not(.active):hover {
  background: #f7faff;
  color: #172033;
}

.chat-text-backend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  color: #526273;
  font-size: 12px;
}
.chat-text-backend select {
  min-width: 168px;
  border: 1px solid #d8e0e8;
  border-radius: 6px;
  background: #fff;
  color: #1f2b37;
  padding: 6px 28px 6px 8px;
}

.composer .chat-mode-switch button.active {
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid #3d7eff;
  border-radius: 6px;
  background: #ffffff;
  color: #2457b8;
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 1px 3px rgb(61 126 255 / 18%);
}

.chat-media-options {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(150px, 1fr) minmax(110px, .7fr) auto minmax(0, .8fr);
  gap: 10px;
  align-items: end;
  padding: 10px 12px;
  border: 1px solid #dfe5ed;
  border-radius: 8px;
  background: #f8fafc;
}

.chat-media-options.hidden,
.chat-media-options .hidden {
  display: none !important;
}

.chat-media-options label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.chat-media-options label > span {
  color: #657387;
  font-size: 12px;
  font-weight: 650;
}

.chat-media-options select,
.chat-media-options .tool {
  width: 100%;
  min-height: 36px;
  margin: 0;
  border: 1px solid #cfd7e3;
  border-radius: 6px;
  background: #fff;
  color: #1d2939;
  font-size: 13px;
}

.chat-media-options .tool {
  padding: 0 13px;
  white-space: nowrap;
}

.chat-media-source-name {
  min-width: 0;
  padding-bottom: 9px;
  overflow: hidden;
  color: #526174;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-media-message {
  display: grid;
  gap: 10px;
  min-width: min(520px, 62vw);
}

.chat-media-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chat-media-message-head strong {
  font-size: 13px;
}

.chat-media-message-head span {
  color: #68768a;
  font-size: 12px;
  font-weight: 650;
}

.chat-media-message-head .status-succeeded { color: #188251; }
.chat-media-message-head .status-failed { color: #b42318; }
.chat-media-message-head .status-cancelled { color: #667085; }
.chat-media-message-head .status-queued,
.chat-media-message-head .status-running { color: #1769aa; }

.chat-media-message img,
.chat-media-message video {
  display: block;
  width: 100%;
  max-width: 640px;
  max-height: 520px;
  border: 1px solid #dfe5ed;
  border-radius: 8px;
  background: #0f1720;
  object-fit: contain;
}

.chat-media-message a {
  width: fit-content;
  color: #1769aa;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.chat-media-message a:hover { text-decoration: underline; }

.chat-media-error {
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

@media (max-width: 900px) {
  .chat-media-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-media-source-name {
    padding-bottom: 0;
  }

  .chat-media-message {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .chat-mode-switch {
    width: 100%;
  }

  .chat-media-options {
    grid-template-columns: 1fr;
  }

  .chat-media-options .tool {
    width: 100%;
  }
}
