.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat__nav {
  flex-shrink: 0;
  background: $bg;
  border-bottom: 1px solid rgba(216, 180, 255, 0.06);
}

.chat__nav-row {
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 12px;
}

.chat__back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: $fg;
}

.chat__back-icon {
  transform: rotate(180deg);
}

.chat__title {
  flex: 1;
  text-align: center;
  color: $fg;
  font: 700 16px / 1 $font-display;
}

.chat__nav-spacer {
  width: 36px;
}

.chat__scroll {
  flex: 1;
  min-height: 0;
}

.chat__list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px;
}

.chat__empty {
  text-align: center;
  color: $muted;
  font: 400 13px / 1.6 $font-body;
  padding: 40px 0;
}

.chat__history-state {
  align-self: center;
  color: $muted;
  font: 400 12px / 1.4 $font-body;
  padding: 2px 0 4px;
}

.chat__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 80%;
}

.chat__row--me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat__bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat__bubble {
  padding: 10px 13px;
  border-radius: 14px;
  background: rgba(45, 34, 85, 0.6);
  border: 1px solid rgba(216, 180, 255, 0.1);
  color: $fg;
  font: 400 14px / 1.5 $font-body;
  word-break: break-word;
}

.chat__bubble--me {
  background: linear-gradient(135deg, $accent, $accent-2);
  border-color: transparent;
  color: $primary-on;
}

.chat__image {
  width: 184px;
  max-width: 60vw;
  height: 132px;
  border-radius: 14px;
  background: rgba(45, 34, 85, 0.6);
  border: 1px solid rgba(216, 180, 255, 0.12);
}

.chat__image--me {
  border-color: rgba(255, 255, 255, 0.24);
}

.chat__time {
  color: $muted;
  font: 400 10px / 1 $font-body;
  padding: 0 4px;
}

.chat__row--me .chat__time {
  text-align: right;
}

.chat__bottom-anchor {
  height: 1px;
}

.chat__emoji-panel {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: $bg;
  border-top: 1px solid rgba(216, 180, 255, 0.08);
}

.chat__emoji {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: rgba(31, 23, 66, 0.68);
  border: 1px solid rgba(216, 180, 255, 0.1);
  text-align: center;
  font: 400 20px / 36px $font-body;
}

.chat__input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 12px;
  background: $bg;
  border-top: 1px solid rgba(216, 180, 255, 0.08);
}

.chat__tool {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: $fg;
  background: rgba(31, 23, 66, 0.68);
  border: 1px solid rgba(216, 180, 255, 0.1);
}

.chat__tool--active {
  color: $primary-on;
  background: rgba(216, 180, 255, 0.18);
  border-color: rgba(216, 180, 255, 0.28);
}

.chat__tool--disabled {
  opacity: 0.45;
}

.chat__input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  box-sizing: border-box;
  border-radius: $radius-pill;
  background: rgba(31, 23, 66, 0.68);
  border: 1px solid rgba(216, 180, 255, 0.1);
  color: $fg;
  font: 400 14px / 40px $font-body;
}

.chat__input-ph {
  color: $muted;
}

.chat__send {
  flex-shrink: 0;
  padding: 0 18px;
  height: 40px;
  border-radius: $radius-pill;
  background: linear-gradient(135deg, $accent, $accent-2);
  color: $primary-on;
  font: 700 14px / 40px $font-body;
}

.chat__send--disabled {
  opacity: 0.5;
}

.chat__send--sending {
  opacity: 0.75;
}
