/* —— 对话：头部 / 时间线 / 气泡 / 输入条 —— */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px;
  /* 顶栏删除后由聊天头承接状态栏安全区，避免内容被刘海/状态栏压住 */
  padding: max(8px, env(safe-area-inset-top)) 8px 8px var(--md-gutter);
  background-color: var(--md-surface);
  border-bottom: 1px solid var(--md-outline-variant);
}
.peer-info { flex: 1; min-width: 0; }
.peer-info h1 {
  font-size: var(--md-title-size); line-height: var(--md-title-line);
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.peer-info p {
  color: var(--md-on-surface-variant);
  font-size: var(--md-label-size); line-height: var(--md-label-line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 聊天背景：底色走四色 token，细网点作纹理（契约 2.3） */
.conversation {
  position: relative;
  flex: 1; min-height: 0;
  overflow: hidden;
  background-color: var(--wp-cream);
  background-image: radial-gradient(var(--wp-dot) 1px, transparent 1px);
  background-size: 18px 18px;
}
.conversation[data-wallpaper="cream"] { background-color: var(--wp-cream); }
.conversation[data-wallpaper="rose"] { background-color: var(--wp-rose); }
.conversation[data-wallpaper="sage"] { background-color: var(--wp-sage); }
.conversation[data-wallpaper="cloud"] { background-color: var(--wp-cloud); }
#wallpaper-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: var(--wallpaper-opacity);
  filter: brightness(var(--wallpaper-brightness));
  outline: var(--img-outline);
  outline-offset: -1px;
  pointer-events: none;
}
.timeline {
  position: relative;
  height: 100%;
  display: flex; flex-direction: column;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px var(--md-gutter) 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.older {
  align-self: center; flex: none;
  min-height: 36px; padding: 0 16px;
  margin-bottom: 8px;
  border-radius: var(--md-shape-full);
  background-color: var(--md-surface-container);
  color: var(--md-primary);
  font-size: var(--md-label-size); line-height: var(--md-label-line);
  font-weight: 500;
}
.older:disabled { color: var(--md-on-surface-variant); }

.messages { display: grid; gap: 8px; margin-top: auto; min-width: 0; }
.messages:empty { display: none; }
.message {
  display: grid; justify-items: start;
  max-width: min(83%, 375px);
  justify-self: start;
  min-width: 0;
}
.message.mine { justify-self: end; justify-items: end; }
.bubble {
  padding: 10px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background-color: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  border-radius: var(--md-shape-lg) var(--md-shape-lg) var(--md-shape-lg) var(--md-shape-xs);
  font-size: var(--md-body-size); line-height: var(--md-body-line);
}
/* 自己的气泡：primary-container 系（契约硬要求） */
.mine .bubble {
  background-color: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border-radius: var(--md-shape-lg) var(--md-shape-lg) var(--md-shape-xs) var(--md-shape-lg);
}
.message time {
  margin-top: 4px;
  color: var(--md-on-surface-variant);
  font-size: 11px; line-height: 16px; font-weight: 500;
}
.day {
  justify-self: center;
  margin: 4px 0;
  padding: 2px 10px;
  border-radius: var(--md-shape-full);
  background-color: var(--md-surface-container);
  color: var(--md-on-surface-variant);
  font-size: var(--md-label-size); line-height: var(--md-label-line);
  font-weight: 500; letter-spacing: .05em;
}
/* 通话记录：居中 tonal 胶囊，不是气泡 */
.message.call-record {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  max-width: 100%; justify-self: center;
  margin: 2px auto;
  padding: 6px 12px;
  border-radius: var(--md-shape-full);
  background-color: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-size: var(--md-label-size); line-height: var(--md-label-line);
  font-weight: 500;
}
.message.call-record time { margin-top: 0; color: var(--md-on-secondary-container); opacity: .8; }
.call-record-icon { display: inline-grid; place-items: center; flex: none; }
.call-record-icon svg { width: 16px; height: 16px; }
.call-record-text { overflow-wrap: anywhere; }

/* 输入条 */
.composer {
  flex: none;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background-color: var(--md-surface);
  border-top: 1px solid var(--md-outline-variant);
}
.composer textarea {
  flex: 1; min-width: 0;
  resize: none;
  min-height: 48px; max-height: 120px;
  padding: 12px 16px;
  border-radius: var(--md-shape-lg);
  field-sizing: content;
}
.send {
  flex: none;
  width: var(--md-touch); height: var(--md-touch);
  display: grid; place-items: center;
  border-radius: 50%;
  background-color: var(--md-primary);
  color: var(--md-on-primary);
  transition: background-image var(--md-dur) var(--md-ease);
}
.send svg { width: 22px; height: 22px; transform: rotate(0deg); }
.send:active { background-image: linear-gradient(var(--md-state-on-primary), var(--md-state-on-primary)); }

/* —— 待发送队列（O 组）：断网入队的消息气泡带状态行与取消/重试操作 —— */
.message.outbox .bubble { outline: 1px dashed var(--md-outline-variant); outline-offset: 2px; }
.outbox-state {
  margin: 2px 4px 0 0;
  font-size: var(--md-label-size);
  line-height: var(--md-label-line);
  color: var(--md-on-surface-variant);
  align-self: flex-end;
  text-align: right;
}
.outbox-state .outbox-action {
  border: none;
  background: none;
  padding: 0 2px;
  font: inherit;
  color: var(--md-primary);
  text-decoration: underline;
  cursor: pointer;
}
.message.outbox.failed .bubble { outline: 1px solid var(--md-error); }
.message.outbox.failed .outbox-state { color: var(--md-error); }

