/* 玩家日志查询Agent 多会话聊天（/ops 专用；不影响 desk/舆情面板样式） */
.plchat {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 14px;
  min-height: 72vh;
  height: calc(100vh - 210px);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.plchat [hidden] { display: none !important; }
@media (max-width: 900px) {
  /* 窄屏单栏：面板不再固定视口高度，列表/消息各自内部滚动，
     使新建/列表/内容/composer 在 1~1.5 屏内全部可达（宿主 .ops-content 垂直滚动） */
  .plchat { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .plchat-side { max-height: 34vh; }
  .plchat-main { min-height: 0; }
  .plchat-feed { max-height: 52vh; }
  .plchat-side-head { min-width: 0; }
  .plchat-side-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .plchat-msg { max-width: 100%; }
}

/* ---- 左：会话列表 ---- */
.plchat-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  border: 1px solid var(--border, #e4e6eb);
  border-radius: 12px;
  background: var(--panel, #fff);
  padding: 12px;
}
.plchat-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plchat-side-title { font-size: 15px; font-weight: 700; color: var(--text, #1a1d23); }
.plchat-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--border, #e4e6eb);
  border-radius: 8px;
  background: var(--panel2, #f4f5f7);
  color: var(--text, #1a1d23);
  font-size: 13px;
}
.plchat-search:focus { outline: 1px solid var(--accent, #3b5bdb); }
.plchat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.plchat-item {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  background: transparent;
  text-align: left;
  width: 100%;
}
.plchat-item:hover { background: var(--panel2, #f4f5f7); }
.plchat-item.active { background: var(--accent-bg, #eef1ff); border-color: var(--accent-dim, #e0e5ff); }
.plchat-item-title {
  font-size: 13px; font-weight: 600; color: var(--text, #1a1d23);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plchat-item-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  font-size: 12px; color: var(--muted, #6b7280);
  overflow: hidden; white-space: nowrap; max-width: 100%;
}
.plchat-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent, #3b5bdb);
  animation: plchat-pulse 1.2s ease-in-out infinite;
  display: inline-block;
}
@keyframes plchat-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.plchat-empty { color: var(--muted, #6b7280); font-size: 13px; padding: 12px 4px; }

/* ---- 右：聊天区 ---- */
.plchat-main {
  display: flex;
  flex-direction: column;
  min-height: 0; min-width: 0;
  border: 1px solid var(--border, #e4e6eb);
  border-radius: 12px;
  background: var(--panel, #fff);
  overflow: hidden;
}
.plchat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e4e6eb);
}
.plchat-head-title {
  font-size: 15px; font-weight: 700; color: var(--text, #1a1d23);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.plchat-head-meta {
  display: flex; align-items: center; gap: 10px; font-size: 12px;
  color: var(--muted, #6b7280); white-space: nowrap; flex: none;
}
.plchat-feed { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.plchat-msg { max-width: min(86%, 100%); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.plchat-msg.user { align-self: flex-end; align-items: flex-end; }
.plchat-msg.assistant { align-self: flex-start; align-items: flex-start; }
.plchat-bubble {
  border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.65;
  border: 1px solid var(--border, #e4e6eb);
  background: var(--panel2, #f4f5f7);
  color: var(--text, #1a1d23);
  overflow-wrap: anywhere; white-space: normal;
  min-width: 0; max-width: 100%;
}
.plchat-msg.user .plchat-bubble { background: var(--accent-bg, #eef1ff); border-color: var(--accent-dim, #e0e5ff); white-space: pre-wrap; }
.plchat-label { font-size: 12px; color: var(--muted, #6b7280); }
.plchat-note { font-size: 13px; color: var(--muted, #6b7280); }
.plchat-note.warn { color: #b45309; }
.plchat-actions { display: flex; gap: 8px; }
.plchat-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted, #6b7280); padding: 4px 2px; }
.plchat-error {
  margin: 0 16px; padding: 8px 12px; border-radius: 8px;
  background: #fef2f2; color: #b91c1c; font-size: 13px;
  border: 1px solid #fecaca;
}
[data-theme="dark"] .plchat-error { background: #3a1d1d; color: #fca5a5; border-color: #57201f; }
.plchat-error[hidden] { display: none; }

/* composer */
.plchat-composer { border-top: 1px solid var(--border, #e4e6eb); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.plchat-composer-row { display: flex; gap: 8px; align-items: flex-end; min-width: 0; }
.plchat-composer-row .btn { flex: none; }
.plchat-input {
  flex: 1; min-width: 0; box-sizing: border-box; resize: none; min-height: 44px; max-height: 160px;
  padding: 9px 11px; border-radius: 10px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border, #e4e6eb); background: var(--panel2, #f4f5f7); color: var(--text, #1a1d23);
}
.plchat-input:focus { outline: 1px solid var(--accent, #3b5bdb); }
.plchat-hint { font-size: 12px; color: var(--muted, #6b7280); }

/* ---- 富文本（安全 markdown 子集渲染） ---- */
.plchat-md { display: flex; flex-direction: column; gap: 8px; }
.plchat-md h1, .plchat-md h2, .plchat-md h3, .plchat-md h4 { margin: 2px 0; font-size: 15px; line-height: 1.4; color: var(--text, #1a1d23); }
.plchat-md h1 { font-size: 17px; } .plchat-md h2 { font-size: 16px; }
.plchat-md p { margin: 0; }
.plchat-md ul, .plchat-md ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; }
.plchat-md code {
  font-family: Consolas, Menlo, monospace; font-size: 13px;
  background: var(--panel-inset, #eef0f2); border-radius: 5px; padding: 1px 5px;
  cursor: copy; border: 1px solid transparent;
}
.plchat-md code:hover { border-color: var(--accent, #3b5bdb); }
.plchat-md strong { font-weight: 700; }
.plchat-codeblock { border: 1px solid var(--border, #e4e6eb); border-radius: 10px; overflow: hidden; background: #0f172a; }
.plchat-codeblock-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 10px; background: #1e293b; color: #cbd5e1; font-size: 12px;
}
.plchat-codeblock pre { margin: 0; padding: 10px 12px; overflow-x: auto; }
.plchat-codeblock code { background: none; border: none; padding: 0; color: #e2e8f0; cursor: auto; font-size: 13px; }
.plchat-md table { border-collapse: collapse; font-size: 13px; max-width: 100%; display: block; overflow-x: auto; }
.plchat-md th, .plchat-md td { border: 1px solid var(--border, #e4e6eb); padding: 5px 9px; text-align: left; }
.plchat-md th { background: var(--panel2, #f4f5f7); font-weight: 600; }
.plchat-copy-ok { color: #15803d !important; }
