.row { display: grid; gap: 14px; }
.messages {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 320px;
  max-height: 52vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}
.message-block {
  max-width: min(680px, 92%);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.message-block.user { align-self: flex-end; align-items: flex-end; }
.message-block.assistant { align-self: flex-start; align-items: flex-start; }
.msg {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 14px 16px;
  border-radius: 16px;
  white-space: pre-wrap;
  line-height: 1.65;
  border: 1px solid rgba(143, 174, 255, 0.14);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg.user { align-self: flex-end; background: linear-gradient(135deg, rgba(43, 67, 126, 0.95), rgba(23, 40, 82, 0.95)); }
.msg.assistant { align-self: flex-start; background: linear-gradient(135deg, rgba(18, 31, 58, 0.98), rgba(11, 22, 44, 0.96)); }
.message-citations {
  display: none;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 4px;
  color: rgba(149, 166, 201, 0.9);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg-meta { display: none; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.65; }
.layout-right { display: grid; gap: 18px; min-width: 0; max-width: 100%; }
.workspace-main { display: grid; gap: 18px; min-width: 0; max-width: 100%; }
.chat-shell { display: grid; gap: 16px; min-width: 0; max-width: 100%; }
.chat-composer {
  border-top: 1px solid rgba(143, 174, 255, 0.14);
  padding-top: 16px;
  display: grid;
  gap: 12px;
}
.chat-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.chat-attachment-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid rgba(143, 174, 255, 0.14);
  border-radius: 14px;
  background: rgba(7, 16, 31, 0.5);
}
.chat-attachment-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chat-attachment-status { color: var(--muted); font-size: 12px; line-height: 1.5; }
.chat-image-preview {
  max-width: min(240px, 100%);
  max-height: 160px;
  border-radius: 14px;
  border: 1px solid rgba(143, 174, 255, 0.18);
  display: none;
  object-fit: contain;
  background: rgba(0,0,0,0.16);
}
.tabbar { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-btn {
  width: auto;
  min-width: 96px;
  padding: 9px 12px;
  font-size: 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(143, 174, 255, 0.14);
  box-shadow: none;
}
.tab-btn.active {
  background: linear-gradient(135deg, rgba(110, 168, 255, 0.22), rgba(79, 124, 255, 0.26));
  border-color: rgba(110, 168, 255, 0.42);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.agent-extra { display: none; }
.agent-extra.show { display: block; }
.asset-extra { display: none; }
.asset-extra.show { display: block; }
.asset-list { display: grid; gap: 12px; }
.asset-item {
  border: 1px solid rgba(143, 174, 255, 0.16);
  background: linear-gradient(180deg, rgba(13, 24, 48, 0.96), rgba(10, 19, 38, 0.96));
  border-radius: 16px;
  padding: 14px;
}
.asset-item.active {
  border-color: rgba(110, 168, 255, 0.54);
  box-shadow: inset 0 0 0 1px rgba(110, 168, 255, 0.2), 0 12px 30px rgba(79, 124, 255, 0.14);
  background: linear-gradient(180deg, rgba(16, 30, 60, 0.98), rgba(11, 22, 44, 0.98));
}
.asset-item.active .asset-name {
  color: #dce8ff;
}
.asset-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.asset-name { font-weight: 700; word-break: break-all; }
.asset-meta { font-size: 12px; color: var(--muted); line-height: 1.6; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 16px 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
pre {
  white-space: pre-wrap;
  overflow: auto;
  min-height: 180px;
  background: rgba(7, 16, 31, 0.9);
  line-height: 1.58;
}
code {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(61, 217, 161, 0.12);
  color: #b6f5de;
  border: 1px solid rgba(61, 217, 161, 0.18);
  font-size: 12px;
  white-space: nowrap;
}
.toast {
  position: sticky;
  top: 12px;
  z-index: 20;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(143, 174, 255, 0.16);
  background: rgba(10, 19, 38, 0.92);
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
  display: none;
}
.toast.show { display: block; }
.toast.success { border-color: rgba(61, 217, 161, 0.28); color: #c8f7e6; }
.toast.error { border-color: rgba(255, 120, 120, 0.32); color: #ffd0d0; }
.toast.info { border-color: rgba(110, 168, 255, 0.28); color: #dce8ff; }
.debug-console {
  position: fixed;
  right: 18px;
  bottom: 76px;
  z-index: 60;
  width: min(560px, calc(100vw - 32px));
  max-height: min(540px, calc(100vh - 112px));
  border: 1px solid rgba(255, 196, 87, 0.32);
  border-radius: 16px;
  background: rgba(22, 18, 8, 0.94);
  box-shadow: 0 14px 38px rgba(0,0,0,0.32);
  backdrop-filter: blur(12px);
  display: none;
  overflow: hidden;
}
.debug-console.open { display: block; }
.debug-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  color: #ffe3a3;
  border-bottom: 1px solid rgba(255, 196, 87, 0.18);
  font-size: 13px;
  font-weight: 800;
}
.debug-body {
  max-height: 240px;
  overflow: auto;
  padding: 10px 12px;
  color: #f8dfaa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.debug-decision {
  max-height: 230px;
  overflow: auto;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 196, 87, 0.18);
  color: #fff3d0;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(255, 196, 87, 0.06);
}
.debug-decision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.debug-decision-card {
  border: 1px solid rgba(255, 196, 87, 0.18);
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.14);
}
.debug-decision-card span {
  display: block;
  color: #e7bd64;
  font-size: 11px;
  margin-bottom: 4px;
}
.debug-decision-card strong {
  display: block;
  color: #fff7df;
  overflow-wrap: anywhere;
}
.debug-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.debug-chip {
  max-width: 100%;
  border: 1px solid rgba(255, 196, 87, 0.22);
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(255, 196, 87, 0.08);
  color: #ffe7ad;
  overflow-wrap: anywhere;
}
.debug-reason {
  margin-top: 8px;
  color: #f7dba0;
}
.debug-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 61;
  width: auto;
  min-width: 84px;
  padding: 11px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 196, 87, 0.96), rgba(224, 138, 48, 0.96));
  color: #241606;
  box-shadow: 0 14px 34px rgba(0,0,0,0.28);
}
@media (max-width: 640px) {
  .debug-decision-grid { grid-template-columns: 1fr; }
}
