/* Process group — 思考 + 工具调用折叠组（参考 Prism .ch-process-group） */

.lian-process-group {
  margin: 2px 0 6px;
  font-size: 10px;
  -webkit-user-select: none;
  user-select: none;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  clear: both;
}

.lian-pg-head {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 2px 6px;
  width: fit-content;
  max-width: 100%;
  min-height: 20px;
  box-sizing: border-box;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(180, 140, 160, 0.2);
  backdrop-filter: blur(10px);
}

.lian-pg-chev {
  width: 10px;
  height: 10px;
  color: var(--gray-9, #8A92A8);
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.lian-process-group.expanded .lian-pg-chev {
  transform: rotate(90deg);
}

.lian-process-group.expanded {
  width: min(100%, 340px);
}

.lian-pg-title {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  color: rgba(92, 58, 71, 0.52);
  text-transform: lowercase;
}

.lian-pg-word {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.lian-pg-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.lian-pg-stat {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  border: 0;
  font-size: 9px;
  color: rgba(92, 58, 71, 0.45);
  line-height: 1;
  white-space: nowrap;
}

.lian-pg-stat-num {
  font-weight: 500;
  white-space: nowrap;
}

.lian-pg-body {
  display: none;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid rgba(180, 140, 160, 0.18);
  width: min(100%, 340px);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 8px 24px rgba(120, 60, 90, 0.08);
  backdrop-filter: blur(14px);
  box-sizing: border-box;
}

.lian-process-group.expanded .lian-pg-body {
  display: block;
}

.lian-pg-thinking {
  font-size: 11px;
  color: rgba(92, 58, 71, 0.72);
  font-style: normal;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 0;
  margin-bottom: 6px;
  background: transparent;
  border-left: 0;
  border-radius: 0;
}

.lian-pg-tool-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(180, 193, 215, 0.28);
  width: 100%;
  box-sizing: border-box;
}

.lian-pg-tool-row:last-child {
  margin-bottom: 0;
}

.lian-pg-tool-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.lian-pg-tool-name {
  font-size: 10px;
  font-weight: 700;
  color: #8A92A8;
  flex-shrink: 0;
}

.lian-pg-tool-summary {
  font-size: 11px;
  color: #5C6478;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lian-pg-tool-detail {
  font-size: 10px;
  color: #8A92A8;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

body.sketch .lian-process-group .lian-pg-title {
  font-family: inherit;
  font-style: normal;
  color: rgba(51, 46, 39, 0.48);
}

body.sketch .lian-process-group {
  width: fit-content;
  max-width: min(100%, 340px);
  margin: 2px 0 6px;
}

body.sketch .lian-pg-head {
  display: inline-flex;
  position: relative;
  width: auto;
  max-width: 100%;
  min-height: 20px;
  padding: 2px 6px;
  border: 1px solid rgba(51, 46, 39, 0.13);
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(255, 253, 248, 0.72), rgba(236, 229, 216, 0.54));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 4px 12px rgba(72, 61, 45, 0.05);
  isolation: isolate;
}

body.sketch .lian-pg-head::after {
  content: "";
  position: absolute;
  inset: 1px -1px -1px 1px;
  border: 1px solid rgba(51, 46, 39, 0.07);
  border-radius: inherit;
  pointer-events: none;
  transform: rotate(-0.35deg);
}

body.sketch .lian-pg-chev {
  color: rgba(51, 46, 39, 0.38);
}

body.sketch .lian-pg-stat {
  color: rgba(51, 46, 39, 0.46);
}

body.sketch .lian-pg-thinking {
  color: rgba(51, 46, 39, 0.72);
  background: transparent;
  border-left-color: transparent;
}

body.sketch .lian-pg-body {
  margin-top: 6px;
  padding: 8px;
  border-color: rgba(51, 46, 39, 0.12);
  background: rgba(255, 253, 248, 0.74);
}

body.sketch .lian-pg-tool-row {
  background: rgba(251, 248, 241, 0.58);
  border-color: rgba(51, 46, 39, 0.14);
  border-radius: 9px 7px 11px 8px;
}

@media (max-width: 520px) {
  body.sketch .lian-process-group {
    max-width: calc(100vw - 92px);
  }

  body.sketch .lian-pg-head {
    gap: 5px;
    padding-right: 7px;
  }

  body.sketch .lian-pg-stats {
    gap: 4px;
  }

  body.sketch .lian-pg-stat {
    padding: 0;
    font-size: 9px;
  }
}

/* ── 气泡内嵌 thinking（lian-pg-inbubble）──
   收进 AI 气泡内部顶部：去掉胶囊框/磨砂底，只留深灰小字标签，
   tokens/用时显示在 thinking 标签右侧（不再撑满整行、不重复到底部）。 */
.lian-pg-inbubble .lian-process-group {
  margin: 0 0 8px;
  width: fit-content;
  max-width: 100%;
}
.lian-pg-inbubble .lian-pg-head {
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  border-radius: 0;
  width: fit-content;
  max-width: 100%;
  gap: 6px;
}
.lian-pg-inbubble .lian-pg-head::after {
  display: none;
}
.lian-pg-inbubble .lian-pg-title {
  color: rgba(60, 50, 55, 0.72);
  flex: 0 0 auto;
}
.lian-pg-inbubble .lian-pg-word {
  color: rgba(60, 50, 55, 0.72);
}
/* tokens / 用时：显示在 thinking 右侧，浅灰小字 */
.lian-pg-inbubble .lian-pg-stats {
  opacity: 0.75;
}
.lian-pg-inbubble .lian-pg-stat {
  color: rgba(60, 50, 55, 0.58);
}
body.sketch .lian-pg-inbubble .lian-pg-head {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
}
