.chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-note {
  font-size: 13px;
  color: #64748b;
  text-align: center;
  line-height: 1.6;
}

.chat-list-item {
  width: 100%;
  text-align: left;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  gap: 3px;
}

.chat-messages {
  flex: 1;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 7px 6px;
  border-radius: 16px;
  background: #ededed;
}

.chat-message {
  --chat-avatar-size: 40px;
  --chat-avatar-gap: 5px;
  --chat-bubble-min-height: 44px;
  --chat-bubble-tail-size: 7px;
  display: grid;
  grid-template-columns: var(--chat-avatar-size) minmax(0, 1fr) var(--chat-avatar-size);
  column-gap: var(--chat-avatar-gap);
  align-items: flex-start;
  width: 100%;
  min-width: 0;
}

.chat-message__avatar-slot {
  width: var(--chat-avatar-size);
  min-width: var(--chat-avatar-size);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.chat-message__avatar-slot--hidden {
  visibility: hidden;
}

.chat-message__avatar-slot .avatar {
  width: var(--chat-avatar-size);
  height: var(--chat-avatar-size);
  border-width: 1px;
}

.chat-message__content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}

.chat-message--user .chat-message__content {
  justify-content: flex-end;
}

.chat-bubble {
  position: relative;
  display: inline-block;
  vertical-align: top;
  max-width: 100%;
  min-height: var(--chat-bubble-min-height);
  box-sizing: border-box;
  padding: 5px 14px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: none;
}

.chat-bubble__text {
  display: block;
  font-size: 30px;
  line-height: 1.05;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-bubble::before {
  content: "";
  position: absolute;
  top: calc((var(--chat-bubble-min-height) - var(--chat-bubble-tail-size)) / 2);
  left: -3px;
  width: var(--chat-bubble-tail-size);
  height: var(--chat-bubble-tail-size);
  background: inherit;
  transform: rotate(45deg);
  border-radius: 1px;
}

.chat-bubble--user {
  background: #95ec69;
}

.chat-bubble--user::before {
  left: auto;
  right: -3px;
}

.chat-bubble--error {
  background: #fef2f2;
  color: #b91c1c;
}

.chat-compose-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-compose__hint {
  margin: 0;
  padding: 0 1px;
  font-size: 10px;
  line-height: 1.35;
  color: #64748b;
}

.chat-compose {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px;
  border-radius: 12px;
  background: #f7f7f7;
  border: 1px solid #d1d5db;
}

.chat-compose__input {
  flex: 1;
  min-height: 24px;
  max-height: 72px;
  resize: none;
  border: 0;
  background: #fff;
  border-radius: 9px;
  padding: 2px 8px;
  font-size: 13px;
  line-height: 1.15;
  outline: none;
}

.chat-compose__actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}

.chat-compose__action {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: #fff;
  color: #475569;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.chat-compose__action:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.chat-compose__action--send {
  background: #22c55e;
  color: #fff;
}

.chat-compose__action--reply {
  border-color: #d1d5db;
}

.chat-compose__icon {
  width: 13px;
  height: 13px;
  display: block;
  flex: 0 0 auto;
}

.chat-compose__icon--reply {
  width: 12px;
  height: 12px;
}

.chat-header__gear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #475569;
}

.chat-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-settings__preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.chat-settings__avatar .avatar {
  width: 72px;
  height: 72px;
  border-width: 3px;
}

.chat-settings__name {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.chat-settings__persona {
  margin: 0;
  color: #64748b;
  line-height: 1.6;
}

.chat-settings__switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.chat-settings__switch input {
  display: none;
}

.chat-settings__switch-box {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.2s ease;
  flex: 0 0 auto;
}

.chat-settings__switch-box::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
  transition: transform 0.2s ease;
}

.chat-settings__switch input:checked + .chat-settings__switch-box {
  background: #22c55e;
}

.chat-settings__switch input:checked + .chat-settings__switch-box::after {
  transform: translateX(20px);
}

.chat-settings__switch-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chat-settings__switch-text strong {
  font-size: 14px;
}

.chat-settings__switch-text small {
  color: #64748b;
  line-height: 1.5;
}
