.chat-app {
  margin: 0 auto;
  max-width: 760px;
}

.chat-heading,
.login-card,
.conversation {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-top: 18px;
  padding: 24px;
}

.chat-heading h1,
.chat-heading p,
.login-card h2 {
  margin-top: 0;
}

.chat-heading p:last-child {
  color: var(--muted);
  margin-bottom: 0;
}

.login-card {
  display: grid;
  gap: 14px;
  max-width: 440px;
}

.login-card label,
.composer label {
  display: grid;
  font-weight: 700;
  gap: 5px;
}

.login-card input,
.composer textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.login-card button,
.composer button {
  background: var(--accent-strong);
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
}

.form-error {
  color: #a22c2c;
  margin: 0;
  min-height: 1.5em;
}

.conversation {
  padding: 0;
  overflow: hidden;
}

.conversation-topbar {
  align-items: center;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.message-list {
  align-content: start;
  background: #faf8f3;
  display: grid;
  gap: 12px;
  max-height: 56vh;
  min-height: 260px;
  overflow-y: auto;
  padding: 18px;
}

.message-list-wrap {
  position: relative;
}

.jump-latest {
  background: var(--accent-strong);
  border: 0;
  border-radius: 999px;
  bottom: 14px;
  box-shadow: 0 4px 14px rgba(27, 79, 82, 0.26);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 13px;
  position: absolute;
  right: 14px;
  z-index: 1;
}

.load-history {
  background: var(--surface-2);
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px;
  width: 100%;
}

.message {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 3px;
  justify-self: start;
  max-width: min(76%, 620px);
  padding: 10px 13px;
  width: fit-content;
}

.message.is-own {
  background: var(--accent-soft);
  border-radius: 12px 12px 3px 12px;
  justify-self: end;
}

.message-meta {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.message-body {
  line-height: 1.65;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-image {
  border-radius: 6px;
  display: block;
  margin-top: 10px;
  max-height: 420px;
}

.message-image.is-clickable {
  cursor: zoom-in;
}

.image-lightbox {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

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

.image-lightbox-backdrop {
  background: rgba(22, 25, 25, 0.82);
  border: 0;
  inset: 0;
  position: absolute;
  width: 100%;
}

.image-lightbox-content {
  margin: 0;
  max-height: 100%;
  max-width: min(1100px, 100%);
  position: relative;
  z-index: 1;
}

.image-lightbox-content img {
  border-radius: 8px;
  display: block;
  max-height: calc(100vh - 48px);
  max-width: 100%;
}

.image-lightbox-close {
  background: #fff;
  border: 0;
  border-radius: 999px;
  color: #222;
  cursor: pointer;
  font-size: 27px;
  height: 38px;
  line-height: 1;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 38px;
}

.delete-message {
  background: transparent;
  border: 0;
  color: #9a4647;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  margin-top: 8px;
  padding: 0;
  text-decoration: underline;
}

.delete-message:hover,
.delete-message:focus-visible {
  color: #70292a;
}

.delete-message:disabled {
  cursor: wait;
  opacity: 0.6;
}

.undo-delete {
  align-items: center;
  background: #242424;
  border-radius: 999px;
  bottom: 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  color: #fff;
  display: flex;
  gap: 12px;
  left: 50%;
  padding: 10px 16px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 30;
}

.undo-delete[hidden] {
  display: none;
}

.undo-delete button {
  background: transparent;
  border: 0;
  color: var(--moon);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 14px;
}

.composer textarea {
  min-height: 92px;
  resize: vertical;
  width: 100%;
}

.composer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

.image-progress {
  background: var(--surface-2);
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px 12px;
}

.image-progress-label {
  display: flex;
  font-size: 14px;
  font-weight: 700;
  justify-content: space-between;
}

.image-progress-track {
  background: #d8d1c4;
  border-radius: 999px;
  height: 9px;
  margin-top: 7px;
  overflow: hidden;
}

.image-progress-track span {
  background: var(--rose);
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 0.45s ease;
  width: 0;
}

.image-progress p {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.sender-switch {
  border: 0;
  display: flex;
  gap: 14px;
  margin: 10px 0 0;
  padding: 0;
}

.sender-switch legend {
  float: left;
  font-weight: 700;
  margin-right: 12px;
}

.sender-switch label {
  align-items: center;
  display: flex;
  font-weight: 400;
  gap: 5px;
}

.composer .secondary-button {
  background: var(--rose);
}
