:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #f2f5f8;
  --text: #172033;
  --muted: #687386;
  --line: #dde4ee;
  --line-strong: #c9d4e4;
  --primary: #2563eb;
  --primary-weak: #eef4ff;
  --green: #149363;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(28, 39, 56, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 310px;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 16px;
  background: #fbfcfe;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark,
.agent-icon,
.mini-icon {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
}

.brand-mark,
.agent-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #12213f;
}

.brand h1,
.agent-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p,
.agent-heading p,
.agent-summary p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.agent-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.agent-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 76px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.agent-item:hover,
.agent-item.active {
  border-color: #bed0ea;
  background: #eef5ff;
}

.mini-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
}

.agent-item strong,
.agent-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-item strong {
  font-size: 14px;
  white-space: nowrap;
}

.agent-item small {
  display: -webkit-box;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.new-chat,
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
}

.new-chat {
  gap: 8px;
  height: 42px;
  border-radius: 8px;
  background: #12213f;
  color: #fff;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  padding: 20px;
}

.topbar,
.agent-heading,
.connection-pill {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  min-height: 48px;
}

.agent-heading {
  gap: 12px;
  min-width: 0;
}

.connection-pill {
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #bfe3d3;
  border-radius: 999px;
  background: #f0fdf7;
  color: #0f6848;
  font-size: 13px;
}

.connection-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.connection-pill.offline {
  border-color: #f2c6bf;
  background: #fff3f1;
  color: var(--danger);
}

.connection-pill.offline span {
  background: var(--danger);
}

.agent-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.agent-summary h3 {
  margin: 5px 0 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.agent-summary span {
  display: block;
  max-width: 820px;
  color: #475467;
  line-height: 1.7;
}

.summary-stats {
  display: flex;
  gap: 10px;
}

.summary-stats div {
  min-width: 80px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.summary-stats strong,
.summary-stats small {
  display: block;
}

.summary-stats strong {
  font-size: 18px;
}

.summary-stats small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.suggestion {
  min-height: 66px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  line-height: 1.45;
  text-align: left;
}

.suggestion:hover {
  border-color: #a8bee4;
  background: #f8fbff;
}

.chat-surface {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 24px;
}

.message {
  display: grid;
  gap: 8px;
  max-width: min(820px, 92%);
}

.message.user {
  align-self: flex-end;
}

.bubble {
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.75;
  word-break: break-word;
}

.message.assistant .bubble {
  border: 1px solid var(--line);
  background: #f8fafc;
}

.message.user .bubble {
  background: var(--primary);
  color: #fff;
}

.message-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-sources span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.process-panel {
  width: fit-content;
  max-width: min(640px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.process-panel summary {
  color: #475467;
  font-weight: 700;
  cursor: pointer;
}

.process-panel ol {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.7;
}

.process-panel li + li {
  margin-top: 2px;
}

.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  height: 21px;
  vertical-align: middle;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8a96a8;
  animation: pulse 1s infinite ease-in-out;
}

.loading-copy {
  display: inline-block;
  margin-left: 10px;
  color: var(--muted);
  font-size: 13px;
  vertical-align: middle;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  padding: 10px 12px;
  line-height: 1.55;
}

.composer textarea:focus {
  border-color: #8fb3e8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.send-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: #fbfcfe;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.inspector h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.knowledge-list,
.output-list,
.source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.knowledge-item,
.output-item,
.source-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  line-height: 1.45;
}

.source-item strong,
.source-item small {
  display: block;
}

.source-item small {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  color: var(--muted);
}

.source-item p,
.empty-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.system-error {
  padding: 14px;
  border: 1px solid #f2c6bf;
  border-radius: 8px;
  background: #fff3f1;
  color: var(--danger);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .inspector {
    display: none;
  }

  .suggestions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .agent-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 245px;
    overflow-x: auto;
  }

  .workspace {
    padding: 14px;
  }

  .agent-summary {
    grid-template-columns: 1fr;
  }

  .summary-stats {
    flex-wrap: wrap;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }
}
