.chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  background: var(--row-hover);
}

.chat__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-12);
  align-items: center;
  padding: var(--space-10) var(--space-16);
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
}

.chat__back {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: calc(-1 * var(--space-12));
  color: var(--primary-text);
}

.chat__avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  font-weight: 700;
  color: var(--primary-text-hover);
  background: var(--primary-soft);
}

.chat__title {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.chat__title b {
  overflow: hidden;
  font-size: var(--font-size-lead);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat__title small,
.chat__hitl-text small {
  font-size: var(--font-size-table-head);
  color: var(--muted);
}

.chat__hitl {
  flex: 1 1 100%;
}

.chat__hitl-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.chat__hitl-text b {
  font-size: var(--font-size-small);
}

.chat__frame {
  display: flex;
  flex: 1;
  min-height: 0;
}

.chat__messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-16);
  overflow: auto;
}

.chat__day {
  align-self: center;
  margin: var(--space-8) 0;
  padding: var(--space-2) var(--space-12);
  font-size: var(--font-size-table-head);
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.chat__compose {
  position: sticky;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: var(--space-10);
  align-items: flex-end;
  padding: var(--space-10) var(--space-16);
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
}

.chat__input {
  flex: 1;
  min-width: 0;
  min-height: var(--control-height);
  max-height: 140px;
  padding: var(--space-10) var(--space-12);
  font: inherit;
  line-height: 1.4;
  resize: none;
  border: 1px solid var(--border);
  field-sizing: content;
}

.chat__note {
  margin: 0;
  padding: var(--space-14) var(--space-16);
  font-size: var(--font-size-small);
  color: var(--muted);
}

.chat__note--bar {
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
}

@media (width >= 720px) {
  .chat__back {
    display: none;
  }

  .chat__compose {
    position: static;
  }

  .chat__hitl {
    flex: none;
    margin-left: auto;
  }

  .chat__head,
  .chat__messages,
  .chat__compose {
    padding-inline: var(--space-20);
  }
}
