
.content-chat{
  max-width:none;
  padding:0;
  height:calc(100vh - 58px);
  overflow:hidden;
}

.agentq-chat{
  --chat-bg:#0f0f0f;
  --chat-panel:#0f0f0f;
  --chat-panel-2:#0f0f0f;
  --chat-line:#2c2c2c;
  --chat-text:#f5f5f5;
  --chat-soft:#d8d8d8;
  --chat-muted:#a3a3a3;
  --chat-good:#78d39a;
  --chat-bad:#e37f7f;
  --chat-accent:#aebaff;

  height:100%;
  min-height:0;
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
  background:var(--chat-bg);
  color:var(--chat-text);
}

.chat-header{
  min-height:76px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  padding:18px 28px;
  border-bottom:1px solid var(--chat-line);
}

.chat-kicker{
  margin:0 0 2px;
  color:var(--chat-muted);
  text-transform:uppercase;
  letter-spacing:.12em;
  font-size:10px;
  font-weight:700;
}

.chat-header h1{
  margin:0;
  font-size:24px;
  line-height:1.1;
  letter-spacing:-.03em;
}

.chat-subtitle{
  margin:4px 0 0;
  color:var(--chat-muted);
  font-size:12px;
}

.chat-agent-health{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.chat-health-card{
  min-width:120px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--chat-line);
  border-radius:11px;
  background:var(--chat-panel);
}

.chat-health-card > span:last-child{
  display:flex;
  flex-direction:column;
  line-height:1.15;
}

.chat-health-card b{font-size:12px}
.chat-health-card small{margin-top:3px;color:var(--chat-muted);font-size:10px}

.chat-health-dot{
  width:7px;
  height:7px;
  border-radius:999px;
  background:#666;
}

.chat-health-dot.ok{background:var(--chat-good)}
.chat-health-dot.bad{background:var(--chat-bad)}

.chat-workspace{
  min-height:0;
  display:grid;
  grid-template-columns:240px minmax(0,1fr);
}

.chat-control-panel{
  min-height:0;
  padding:16px 14px;
  border-right:1px solid var(--chat-line);
  background:var(--chat-bg);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.chat-new-btn{
  width:100%;
  min-height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  border:1px solid #343434;
  border-radius:10px;
  background:#202020;
  color:var(--chat-text);
  cursor:pointer;
  font-weight:700;
}

.chat-new-btn:hover{background:#282828}

.chat-section-title{
  padding:15px 7px 6px;
  color:var(--chat-muted);
  text-transform:uppercase;
  letter-spacing:.09em;
  font-size:10px;
  font-weight:800;
}

.chat-agent-row{
  position:relative;
  min-height:43px;
  margin:1px 0;
  padding:7px;
  border-radius:9px;
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:8px;
  cursor:pointer;
}

.chat-agent-row:hover{background:#ffffff08}
.chat-agent-row > span:first-child{display:flex;flex-direction:column}
.chat-agent-row b{font-size:13px}
.chat-agent-row small{color:var(--chat-muted);font-size:11px}
.chat-agent-row input{position:absolute;opacity:0;pointer-events:none}

.chat-switch{
  width:29px;
  height:17px;
  border-radius:999px;
  background:#3b3b3b;
  position:relative;
  transition:.15s ease;
}

.chat-switch::after{
  content:"";
  position:absolute;
  width:11px;
  height:11px;
  left:3px;
  top:3px;
  border-radius:50%;
  background:#aaa;
  transition:.15s ease;
}

.chat-agent-row input:checked + .chat-switch{background:#59627f}
.chat-agent-row input:checked + .chat-switch::after{
  transform:translateX(12px);
  background:#fff;
}

.chat-divider{height:1px;background:var(--chat-line);margin:9px 5px}

.chat-duet-options{
  margin:4px 2px;
  padding:5px;
  border:1px solid var(--chat-line);
  border-radius:10px;
  background:#171717;
}

.chat-duet-options[hidden]{display:none}

.chat-duet-options label{
  display:flex;
  gap:7px;
  align-items:flex-start;
  padding:6px;
  border-radius:8px;
  cursor:pointer;
}

.chat-duet-options label:hover{background:#ffffff07}
.chat-duet-options span{display:flex;flex-direction:column}
.chat-duet-options b{font-size:12px}
.chat-duet-options small{color:var(--chat-muted);font-size:10px}

.chat-recent-list{
  min-height:0;
  flex:1;
  overflow-y:auto;
  overscroll-behavior:contain;
}

.recent-bulk-toolbar{
  position:sticky;
  top:0;
  z-index:2;
  padding:6px 2px;
  background:var(--chat-bg);
  display:flex;
  justify-content:space-between;
  gap:5px;
}

.recent-select-all{
  display:flex;
  align-items:center;
  gap:4px;
  color:var(--chat-muted);
  font-size:9px;
}

.recent-bulk-delete{
  border:0;
  background:transparent;
  color:#dc8d8d;
  font-size:8px;
  cursor:pointer;
}
.recent-bulk-delete:disabled{opacity:.35;cursor:default}

.recent-row{
  display:grid;
  grid-template-columns:20px minmax(0,1fr) 24px;
  align-items:center;
  gap:2px;
}

.recent-select-wrap{
  display:grid;
  place-items:center;
}

.recent-select{width:12px;height:12px}

.recent-item{
  min-width:0;
  padding:7px;
  border:0;
  border-radius:8px;
  background:transparent;
  color:#cfcfcf;
  text-align:left;
  cursor:pointer;
  display:flex;
  flex-direction:column;
}

.recent-item:hover,.recent-item.active{
  background:#ffffff0a;
  color:#fff;
}

.recent-title{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:12px;
}

.recent-meta{margin-top:2px;color:var(--chat-muted);font-size:9px}

.recent-delete{
  border:0;
  background:transparent;
  color:#777;
  cursor:pointer;
}
.recent-delete:hover{color:#e18b8b}
.recent-empty{padding:10px 7px;color:var(--chat-muted);font-size:11px}

.chat-runtime{
  margin-top:8px;
  padding:8px 6px 2px;
  border-top:1px solid var(--chat-line);
  color:var(--chat-muted);
  font-size:9px;
  letter-spacing:.07em;
}

.chat-runtime-dot{
  display:inline-block;
  width:6px;height:6px;
  margin-right:5px;
  border-radius:50%;
  background:#d0b06c;
}

.chat-conversation-panel{
  min-width:0;
  min-height:0;
  display:grid;
  grid-template-rows:minmax(0,1fr) auto;
  background:var(--chat-bg);
}

.chat-conversation{
  min-width:0;
  min-height:0;
  overflow-y:auto;
  padding:26px max(22px, calc((100% - 820px)/2));
  scroll-behavior:smooth;
}

.chat-welcome{
  min-height:100%;
  display:grid;
  place-content:center;
  justify-items:center;
  text-align:center;
  color:var(--chat-muted);
}

.chat-orb{
  width:44px;height:44px;
  display:grid;place-items:center;
  margin-bottom:14px;
  border:1px solid #3b3b3b;
  border-radius:14px;
  background:#1d1d1d;
  color:#eee;
  font-weight:800;
}

.chat-welcome h2{margin:0;color:var(--chat-text)}
.chat-welcome p{margin:7px 0 0;font-size:12px}

.chat-composer{
  margin:0 max(22px, calc((100% - 820px)/2)) 20px;
  padding:8px;
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto;
  gap:7px;
  align-items:end;
  border:1px solid #3a3a3a;
  border-radius:14px;
  background:#262626;
}

.chat-composer textarea{
  width:100%;
  max-height:170px;
  min-height:34px;
  padding:7px 8px;
  resize:none;
  border:0;
  outline:0;
  background:transparent;
  color:var(--chat-text);
  font:inherit;
  font-size:14px;
  line-height:1.45;
}

.chat-style{
  height:34px;
  border:0;
  outline:0;
  background:transparent;
  color:#ccc;
  font-size:11px;
}

.chat-style option{background:#222;color:#fff}

.chat-send-btn{
  height:34px;
  padding:0 13px;
  border:1px solid #454545;
  border-radius:9px;
  background:#eee;
  color:#111;
  cursor:pointer;
  font-weight:750;
  font-size:12px;
}

.chat-send-btn:hover{background:#fff}
.chat-send-btn.agent-disabled{opacity:.45}

.agent-inactive-notice{
  position:fixed;
  left:50%;
  bottom:26px;
  transform:translate(-50%,18px);
  z-index:100;
  opacity:0;
  padding:9px 12px;
  border:1px solid #454545;
  border-radius:10px;
  background:#222;
  color:#eee;
  transition:.18s ease;
  pointer-events:none;
  font-size:11px;
}
.agent-inactive-notice.show{opacity:1;transform:translate(-50%,0)}

.task{margin-bottom:22px}
.user-bubble{
  width:fit-content;
  max-width:80%;
  margin-left:auto;
  padding:11px 13px;
  border:1px solid #3b3b3b;
  border-radius:14px;
  background:#2a2a2a;
  color:#f6f6f6;
  white-space:pre-wrap;
}
.label{
  margin-bottom:5px;
  color:#aaa;
  font-size:9px;
  font-weight:800;
  letter-spacing:.05em;
  text-transform:uppercase;
}

.agent-bubble{
  margin-top:15px;
  padding:14px 16px;
  border:1px solid #303030;
  border-radius:14px;
  background:#181818;
}
.agent-bubble.final{border-color:#424242;background:#1d1d1d}
.bubble-head{display:flex;align-items:center;justify-content:space-between;gap:12px}
.copy-btn{
  padding:4px 7px;
  border:1px solid #353535;
  border-radius:7px;
  background:#ffffff05;
  color:#aaa;
  cursor:pointer;
  font-size:9px;
}
.copy-btn:hover{color:#fff;background:#ffffff0d}

.markdown-body{color:#ededed;font-size:13px;line-height:1.65;overflow-wrap:anywhere}
.markdown-body p{margin:8px 0}
.markdown-body ul,.markdown-body ol{padding-left:22px}
.markdown-body pre{overflow:auto;padding:12px;border:1px solid #303030;border-radius:9px;background:#0b0b0b}
.markdown-body code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
.markdown-body :not(pre)>code{padding:1px 4px;border-radius:5px;background:#252525}

.pipeline{
  margin-top:10px;
  display:flex;
  align-items:center;
  gap:7px;
  color:#aaa;
  font-size:10px;
}
.pulse{width:6px;height:6px;border-radius:50%;background:#b4c1ff;box-shadow:0 0 0 0 #b4c1ff66;animation:agentq-pulse 1.4s infinite}
@keyframes agentq-pulse{70%{box-shadow:0 0 0 7px transparent}}
.warning{
  margin-top:10px;
  padding:9px 11px;
  border:1px solid #674848;
  border-radius:9px;
  background:#3a2222;
  color:#efb2b2;
  font-size:11px;
}

.history-chat{display:flex;flex-direction:column;gap:4px}

.chat-recent-list,.chat-conversation{
  scrollbar-width:thin;
  scrollbar-color:#3d3d3d transparent;
}

@media (max-width: 900px){
  .content-chat{height:auto;min-height:calc(100vh - 58px);overflow:visible}
  .agentq-chat{min-height:calc(100vh - 58px)}
  .chat-header{align-items:flex-start}
  .chat-workspace{grid-template-columns:1fr}
  .chat-control-panel{
    max-height:none;
    border-right:0;
    border-bottom:1px solid var(--chat-line);
  }
  .chat-recent-list{max-height:170px}
  .chat-conversation-panel{min-height:70vh}
  .chat-conversation{padding:20px 15px}
  .chat-composer{margin:0 15px 15px}
}


.chat-memory-btn{
  width:100%;
  min-height:36px;
  margin:7px 0 2px;
  padding:7px 10px;
  display:grid;
  grid-template-columns:18px minmax(0,1fr) auto;
  align-items:center;
  gap:7px;
  border:0;
  border-radius:9px;
  background:transparent;
  color:#cfcfcf;
  cursor:pointer;
  text-align:left;
  font-weight:700;
  font-size:11px;
}
.chat-memory-btn:hover{background:#ffffff08;color:#fff}
.chat-memory-count{
  min-width:18px;
  padding:1px 5px;
  border-radius:999px;
  background:#8996ff18;
  color:#c5ceff;
  text-align:center;
  font-size:9px;
}
.chat-memory-count:empty{display:none}

body.memory-open{overflow:hidden}

.memory-overlay{
  position:fixed;
  inset:0;
  z-index:12000;
  display:flex;
  justify-content:flex-end;
  background:#000000b8;
  backdrop-filter:blur(5px);
}
.memory-overlay[hidden]{display:none}

.memory-panel{
  width:min(680px,100vw);
  height:100dvh;
  display:grid;
  grid-template-rows:auto auto auto minmax(0,1fr);
  border-left:1px solid #343434;
  background:var(--chat-bg);
  box-shadow:-24px 0 80px #0008;
}

.memory-panel-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:20px;
  padding:24px 24px 18px;
  border-bottom:1px solid #2e2e2e;
}
.memory-panel-header h2{margin:2px 0 3px;font-size:24px}
.memory-panel-header p{margin:0;color:#999;font-size:12px}

.memory-close-btn{
  width:36px;height:36px;
  border:1px solid #333;
  border-radius:10px;
  background:#ffffff05;
  color:#ddd;
  cursor:pointer;
  font-size:22px;
}

.memory-toolbar{
  display:grid;
  grid-template-columns:minmax(160px,1fr) auto auto auto;
  gap:8px;
  padding:13px 16px 9px;
}

.memory-search,.memory-filter{
  min-width:0;
  height:36px;
  border:1px solid #383838;
  border-radius:9px;
  outline:0;
  background:#202020;
  color:#f5f5f5;
  font-size:12px;
}
.memory-search{padding:0 10px}
.memory-filter{padding:0 8px}

.memory-add-btn{
  height:36px;
  padding:0 12px;
  border:1px solid #5963a3;
  border-radius:9px;
  background:#8996ff18;
  color:#d7ddff;
  cursor:pointer;
  font-size:12px;
  font-weight:800;
}

.memory-summary-row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:0 18px 10px;
  color:#999;
  font-size:10px;
  font-weight:700;
}

.memory-list{
  min-height:0;
  overflow-y:auto;
  padding:4px 16px 22px;
}

.memory-card{
  margin:0 0 9px;
  padding:14px;
  border:1px solid #323232;
  border-left:3px solid #5f6675;
  border-radius:12px;
  background:#1b1b1b;
}
.memory-card.pinned{
  border-left-color:#a99cff;
  background:linear-gradient(135deg,#24212d,#1b1b1b);
}

.memory-card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.memory-badges{display:flex;flex-wrap:wrap;gap:5px}
.memory-badge{
  padding:3px 6px;
  border:1px solid #343434;
  border-radius:999px;
  background:#ffffff04;
  color:#aaa;
  font-size:9px;
  font-weight:800;
  letter-spacing:.05em;
}
.badge-pinned{color:#d8d0ff;border-color:#6d63a0}
.badge-global{color:#bec8ff;border-color:#56618f}
.memory-importance{color:#d9c46b;font-size:9px}
.memory-card h3{margin:10px 0 5px;font-size:14px}
.memory-content{
  color:#e3e3e3;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  font-size:12px;
  line-height:1.5;
}
.memory-meta{
  display:flex;
  flex-wrap:wrap;
  gap:4px 12px;
  margin-top:10px;
  color:#777;
  font-size:9px;
}
.memory-actions{
  display:flex;
  justify-content:flex-end;
  gap:6px;
  margin-top:10px;
}
.memory-actions button,
.memory-btn-primary,
.memory-btn-secondary{
  min-height:30px;
  padding:0 10px;
  border:1px solid #373737;
  border-radius:8px;
  background:#ffffff05;
  color:#ccc;
  cursor:pointer;
  font-size:11px;
  font-weight:750;
}
.memory-actions button.danger{color:#ee9f9f}
.memory-btn-primary{
  border-color:#616da9;
  background:#8996ff20;
  color:#d5dbff;
}

.memory-editor-grid{
  display:grid;
  grid-template-columns:1.5fr 1fr .8fr .8fr .7fr;
  gap:7px;
}
.memory-editor-grid label,
.memory-content-label{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.memory-editor-grid label > span,
.memory-content-label > span{
  color:#999;
  font-size:9px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.07em;
}
.memory-editor-grid input,
.memory-editor-grid select,
.memory-content-label textarea{
  width:100%;
  border:1px solid #343434;
  border-radius:8px;
  outline:0;
  background:#202020;
  color:#f4f4f4;
  font-size:12px;
}
.memory-editor-grid input,
.memory-editor-grid select{height:34px;padding:0 8px}
.memory-content-label{margin-top:9px}
.memory-content-label textarea{min-height:90px;padding:8px 9px;resize:vertical}
.memory-editor-actions{
  display:flex;
  justify-content:flex-end;
  gap:6px;
  margin-top:9px;
}
.memory-loading,.memory-empty{
  padding:44px 18px;
  color:#888;
  text-align:center;
  font-size:12px;
}

@media(max-width:760px){
  .memory-panel{width:100vw}
  .memory-panel-header{padding:17px 15px 13px}
  .memory-toolbar{grid-template-columns:minmax(0,1fr) 1fr}
  .memory-search{grid-column:1/-1}
  .memory-add-btn{grid-column:1/-1}
  .memory-editor-grid{grid-template-columns:1fr 1fr}
  .memory-editor-grid label:first-child{grid-column:1/-1}
}
