/* 整页贴合 visualViewport（--vv-h / --vv-top 由 chat.js 写入），顶栏+列表+输入栏同一 flex 柱 */
.chat {
  --vv-h: 100%;
  --vv-top: 0px;
  --composer-pad-bottom: calc(8px + var(--safe-bottom));
  position: absolute;
  top: 0;
  left: 50%;
  width: 100%;
  max-width: var(--app-max);
  height: var(--vv-h);
  transform: translateX(-50%) translateY(var(--vv-top));
  will-change: transform, height;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--chat-bg);
}

.chat > .navbar {
  flex: none;
  background: var(--chat-bar);
  box-shadow: 0 0.5px 0 var(--separator);
}

.chat__list {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 0;
  background: var(--chat-bg);
}

/* ---------- 消息 ---------- */

.msg {
  padding: 8px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.msg--self {
  flex-direction: row-reverse;
}

.msg .avatar {
  --size: 40px;
  border-radius: var(--radius-s);
}

.msg__bubble {
  position: relative;
  max-width: min(75%, 480px);
  padding: 10px 14px;
  border-radius: var(--radius-m);
  background: var(--bubble-other);
  color: var(--bubble-other-text);
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg__bubble::before {
  content: "";
  position: absolute;
  top: 14px;
  left: -5px;
  border: 5px solid transparent;
  border-left: 0;
  border-right-color: var(--bubble-other);
}

.msg--self .msg__bubble {
  background: var(--bubble-self);
  color: var(--bubble-self-text);
}

.msg--self .msg__bubble::before {
  left: auto;
  right: -5px;
  border-right: 0;
  border-left: 5px solid var(--bubble-self);
}

/* ---------- 输入栏 ---------- */

.composer {
  flex: none;
  padding: 8px 10px var(--composer-pad-bottom);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--chat-bar);
  box-shadow: 0 -0.5px 0 var(--separator);
}

.composer__input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  outline: none;
  resize: none;
  background: var(--chat-input);
  font-size: 16px;
  line-height: 22px;
}

.composer__btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.composer__btn .icon {
  width: 28px;
  height: 28px;
}

.composer__send {
  flex: none;
  height: 36px;
  margin-bottom: 2px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--chat-send);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 500;
}

.composer:not(.has-text) .composer__send,
.composer.has-text .composer__btn {
  display: none;
}

.composer.is-sending .composer__send,
.composer.is-sending .composer__btn {
  opacity: 0.45;
  pointer-events: none;
}
