/* ============================================================
   好好聊 · 对话线程样式
   整个应用就是一条线程：左边是 TA，右边是教练。
   ============================================================ */

/* ---------- 顶部：当前对象 ---------- */

.who {
  grid-area: 1 / 2;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 0;
  text-align: center;
  color: inherit;
  min-width: 0;
}

.who__name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.who__meta {
  font-size: 11.5px;
  color: var(--fg-4);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- 线程容器 ---------- */

.screen--thread {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: 0;
}

.thread {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: var(--sp-2) 0 var(--sp-5);
}
#generation-preview[hidden],
.screen--thread:has(#generation-preview:not([hidden])) .thread__empty { display: none; }
#generation-preview { margin-bottom: var(--sp-5); }
.sug--skeleton {
  display: grid;
  align-content: center;
  gap: 12px;
  min-height: 88px;
}
.sug--skeleton span {
  display: block;
  width: 78%;
  height: 12px;
  border-radius: 999px;
  background: var(--line-2);
}
.sug--skeleton span:first-child { width: 28%; }
.thread__speech {
  display: flex;
  align-self: center;
  align-items: center;
  min-height: var(--control-height);
  padding-inline: 8px;
  text-align: center;
  font-size: 13px;
  color: var(--fg-2);
}
.thread__speech:hover { color: var(--fg); }

.thread__empty {
  max-width: 18rem;
  margin: auto;
  padding: 12px 14px;
  text-align: center;
}
.thread__empty h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-3);
}
.thread__empty p {
  margin-top: 6px;
  color: var(--fg-4);
  font-size: 14px;
  line-height: 1.6;
}

.thread__mode-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-height);
  color: var(--fg-2);
  font-size: 13px;
}
.thread__mode-link:hover { color: var(--fg); }
.thread__empty .thread__mode-link {
  gap: 8px;
  margin-top: 12px;
  padding-inline: 16px;
  border: 1px solid var(--accent-line);
  border-radius: var(--control-radius);
  background: var(--accent-soft);
  color: var(--accent-hi);
  font-size: var(--control-font-size);
  font-weight: 600;
}
.thread__empty .thread__mode-link:is(:hover, :active) { border-color: var(--accent); }
.composer__mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--fg-2);
  font-size: 14px;
}

/* ---------- 一轮往来 ---------- */

.turn {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  animation: screenIn var(--dur-3) var(--ease-out) both;
}

.bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 14.5px;
  line-height: 1.72;
}

.bubble__who {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-bottom: 5px;
}

/* TA 的话：左 */
.bubble--them {
  position: relative;
  align-self: flex-start;
  margin-inline-start: 5px;
  background: var(--surface-solid);
}
.bubble--them::before {
  content: "";
  position: absolute;
  inset-inline-start: -5px;
  top: 14px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: inherit;
}

.bubble--them .bubble__text {
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 对方只发了一张图 / 表情包（没有文字）时的占位 */
.bubble--them .bubble__img {
  color: var(--fg-3);
  font-size: 13px;
  line-height: 1.6;
}

/* 教练的话：右 */
.bubble--coach {
  align-self: flex-end;
  width: 100%;
  max-width: 94%;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: var(--r-lg);
  border-bottom-right-radius: 8px;
}

.coach__style {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--fg-4);
}

.turn__sent {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--sage);
  line-height: 1.6;
}

/* 教练气泡里的建议卡 */
.bubble--coach .sug {
  margin-top: 10px;
  background: var(--surface);
  border-color: var(--line);
}
.bubble--coach .sug.is-copied { border-color: var(--sage); }
.sug.is-copied [data-act="copy"] {
  color: var(--sage);
  background: var(--sage-soft);
  border-color: transparent;
}

.bubble--coach .sug__text {
  font-size: 14.5px;
  line-height: 1.7;
}

/* 教练气泡里的「我看见了什么」 */
.read {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.read__mark {
  flex: none;
  font-size: 14px;
  line-height: 1.5;
  opacity: 0.85;
}

.read__seen {
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-2);
}

/* 猜测必须**标出来是猜测** —— 模型读表情包会猜，而且猜错了不会说 */
.read__guess {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--fg-4);
}

.coach__warn {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ember);
}

/* ---------- 输入区 ---------- */

.composer {
  position: sticky;
  z-index: 20;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-inline: calc(-1 * var(--screen-start)) calc(-1 * var(--screen-end));
  padding: 10px var(--screen-end) calc(env(safe-area-inset-bottom) + 12px) var(--screen-start);
  background: var(--surface-solid);
  border-top: 1px solid var(--line);
}

/* 待发的图（对方发来的图/表情包） */
.chat-attachments__previews {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-attachments__previews::-webkit-scrollbar { display: none; }

.chip--img {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.chip--img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chip--img__x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.composer .textarea--chat {
  min-height: var(--chat-input-min-height);
  max-height: 30vh;
}

.composer__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.composer__meta .thread__mode-link {
  position: relative;
  min-height: 24px;
  margin-inline-start: auto;
  color: var(--accent-hi);
}

.composer__meta .thread__mode-link::before {
  position: absolute;
  inset: -10px -2px;
  content: '';
}

.composer__hint {
  font-size: 12px;
  color: var(--fg-4);
}

.composer__quota {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.generation-status { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 8px; color: var(--fg-2); font-size: 13px; }
.generation-status[hidden] { display: none; }
.generation-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.generation-error[hidden] { display: none; }

.quota-member {
  border: 0;
  background: none;
  color: var(--accent-hi);
  text-decoration: underline;
  padding: 4px 0;
  min-height: 44px;
  cursor: pointer;
}

.composer .generation-status,
.composer .generation-error { margin-top: 0; }

.contact-background { min-width: 0; margin: 0; padding: 0; border: 0; }
.contact-background legend { margin-bottom: 8px; color: var(--fg-2); font-size: 14px; }
.contact-background__choices { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-background__choices .chip { cursor: pointer; }
.contact-background__choices .chip:has(:checked) { color: var(--accent-hi); border-color: var(--accent-line); background: var(--accent-soft); }
.contact-background__choices .chip:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.contact-background__choices input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.contact-background__detail { margin-top: var(--sp-3); }
.contact-background__detail[hidden] { display: none; }
.contact-background__example { display: block; margin-top: 6px; color: var(--fg-3); font-size: 13px; }
.sheet--intake .contact-background + .field { margin-top: var(--field-gap); }

/* ---------- 建档：截图 ---------- */

.sheet__lead {
  font-size: 13px;
  color: var(--fg-3);
  line-height: 1.7;
  margin-bottom: 14px;
}

.uploader {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  cursor: pointer;
}

.uploader__btn {
  font-size: 14px;
  color: var(--accent-hi);
}

.uploader__hint {
  font-size: 12px;
  color: var(--fg-4);
  line-height: 1.6;
}

.shots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.shots:empty { margin-top: 0; }
/* 展开认识方式的补充字段时，保留用户正在看的选项位置。 */
.sheet--intake .sheet__body { overflow-anchor: none; }
.sheet--intake .sheet__body > .field + .field { margin-top: var(--field-gap); }
.sheet--intake .field + .field--goal-options { margin-top: 10px; }
.sheet--intake #f-goal { min-height: 84px; }
.sheet--intake .more { margin-top: 20px; }

.shot {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shot__x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
}

/* ---------- 聊天对象列表 ---------- */

.thread-topbar__edit { padding-inline: 6px; white-space: nowrap; }
.thread-topbar__edit#edit-contact {
  min-width: 44px;
  min-height: 44px;
  padding-inline: 0;
  border-color: transparent;
  font-size: 22px;
  line-height: 1;
}
.contact-list, .contact-list__quick {
  margin-inline: calc(-1 * var(--screen-start)) calc(-1 * var(--screen-end));
  background: var(--surface-solid);
}
.contact-list__quick {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: 8px;
  padding: 10px var(--screen-end) 10px var(--screen-start);
  border-bottom: 1px solid var(--line);
  color: var(--fg);
}
.contact-list__quick strong { display: block; font-size: 16px; font-weight: 600; }
.contact-list__quick small { display: block; color: var(--fg-3); font-size: 13px; }
.contact-list { list-style: none; padding: 0; }
.contact-list > li + li::before {
  content: "";
  display: block;
  margin-inline-start: calc(var(--screen-start) + 42px + var(--sp-3));
  border-top: 1px solid var(--line);
}
.sheet--contact-actions {
  padding: 0 0 env(safe-area-inset-bottom);
  background: var(--bg);
}
.sheet--contact-actions .sheet__grip { display: none; }
.sheet--contact-actions .sheet__actions { margin-top: 8px; }
.contact-actions .btn, .sheet--contact-actions > .stack-sm .btn {
  min-height: 52px;
  border: 0;
  border-radius: 0;
  background: var(--surface-solid);
  font-size: 16px;
}
.contact-actions .btn + .btn { border-top: 1px solid var(--line); }
.contact-actions .btn:active, .sheet--contact-actions > .stack-sm .btn:active {
  background: var(--surface-2);
}
.contact-list__context {
  position: fixed;
  z-index: 51;
  width: min(160px, calc(100vw - 16px));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-solid);
  box-shadow: var(--shadow-pop);
}
.contact-list__context button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: calc(var(--r-md) - 4px);
  background: transparent;
  color: var(--fg);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.contact-list__context button:hover, .contact-list__context button:focus-visible { background: var(--surface-2); }
.contact-actions .contact-action--delete, .contact-list__context .contact-action--delete { color: var(--ember); }
.contact-list__row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  min-height: 70px;
  padding: 10px var(--screen-end) 10px var(--screen-start);
  color: var(--fg);
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-touch-callout: none;
}
.contact-list__row:hover, .contact-list__quick:hover { background: var(--surface-2); }
.contact-list__avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: 17px;
}
.contact-list__avatar--quick {
  background: var(--accent-soft);
  color: var(--accent-hi);
}
.contact-list__main { display: grid; gap: 2px; min-width: 0; }
.contact-list__name, .contact-list__summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-list__name { font-size: 16px; font-weight: 500; }
.contact-list__summary { color: var(--fg-3); font-size: 13px; }
.contact-list__time { align-self: start; color: var(--fg-3); font-size: 12px; white-space: nowrap; }
.contact-list__empty { padding: var(--sp-4) 8px; color: var(--fg-3); }

.chat-attachments { display: grid; gap: var(--sp-3); padding-bottom: 14px; }
.chat-attachments__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.chat-attachments .form-feedback { margin: 0; }
.chat-attachments .form-feedback:empty { position: absolute; }
.chat-attachments__previews:empty { display: none; }
.chat-attachments [data-ocr-preview][hidden] { display: none; }
.chat-attachments-footer { display: grid; grid-template-columns: 1fr 2fr; gap: var(--sp-2); }
.chat-attachments-footer > * + * { margin-top: 0; }
