.chat-composer {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.chat-photo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 78px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fbff;
  color: var(--primary);
  padding: 9px 11px;
  font-size: 11px;
  font-weight: 800;
}

.chat-photo-button:hover {
  border-color: #9fc9ef;
  background: #edf6ff;
}

.chat-photo-button svg {
  width: 18px;
  height: 18px;
}

.chat-image-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid #cfe2f5;
  border-radius: 12px;
  background: #f5faff;
  padding: 9px;
}

.chat-image-preview[hidden] {
  display: none;
}

.chat-image-preview img {
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 9px;
  object-fit: cover;
}

.chat-image-preview div {
  min-width: 0;
  flex: 1;
}

.chat-image-preview strong,
.chat-image-preview small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-image-preview strong {
  font-size: 11px;
}

.chat-image-preview small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.chat-image-preview button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}

.chat-image-preview button:hover {
  background: #fff;
  color: #dc2626;
}

.chat-image-preview button svg {
  width: 15px;
  height: 15px;
}

.chat-bubble.has-image {
  width: min(360px, 68vw);
}

.chat-photo {
  width: 100%;
  display: block;
  overflow: hidden;
  margin: 2px 0 7px;
  border-radius: 10px;
  background: #e7eef6;
  line-height: 0;
}

.chat-photo img {
  width: 100%;
  max-height: 360px;
  display: block;
  object-fit: contain;
}

.chat-image-backdrop {
  z-index: 60;
}

.chat-image-viewer {
  position: relative;
  width: min(980px, 94vw);
  max-height: 92vh;
  display: grid;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 17px;
  background: #0b1220;
  padding: 12px;
  box-shadow: 0 35px 90px rgba(0, 0, 0, .45);
}

.chat-image-viewer > img {
  width: 100%;
  max-height: calc(92vh - 76px);
  border-radius: 11px;
  object-fit: contain;
}

.chat-image-viewer > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  padding: 0 4px 2px;
}

.chat-image-viewer > div span {
  color: #a9b7cb;
  font-size: 10px;
}

.chat-image-close {
  position: absolute;
  z-index: 1;
  top: 20px;
  right: 20px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(11, 18, 32, .78);
  color: #fff;
  backdrop-filter: blur(8px);
}

.chat-image-close svg {
  width: 18px;
  height: 18px;
}

html.theme-dark .chat-photo-button,
html.theme-dark .chat-image-preview {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

html.theme-dark .chat-photo-button:hover,
html.theme-dark .chat-image-preview button:hover {
  background: var(--surface-3);
}

@media (max-width: 650px) {
  .chat-composer {
    gap: 8px;
    padding: 12px;
  }

  .chat-photo-button {
    min-width: 42px;
    padding: 9px;
  }

  .chat-photo-button span {
    display: none;
  }

  .chat-bubble.has-image {
    width: min(330px, 76vw);
  }

  .chat-image-viewer > div {
    align-items: flex-start;
    flex-direction: column;
  }
}
