:root {
  --bg: #1e1e1e;
  --bg-panel: #252526;
  --bg-deep: #181818;
  --bg-card: #1b1b1b;
  --border: #333;
  --text: #d6d6d6;
  --text-dim: #8b8b8b;
  --text-bright: #f0f0f0;
  --accent: #007acc;
  --ok: #3fb950;
  --err: #f85149;
  --add: #3fb950;
  --del: #f85149;
  --user-bg: #2a3140;
  --font-ui: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "Sarasa Mono SC", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-panel);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: default;
}

.agent-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg-panel);
}

.agent-head {
  flex-shrink: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid #2c2c2c;
  color: var(--text-dim);
  user-select: none;
}

.head-title {
  font-size: 12px;
  letter-spacing: 0.02em;
}

.head-tools {
  display: flex;
  gap: 12px;
  opacity: 0.7;
}

.agent-stream {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

/* —— 消息块 —— */
.msg {
  margin: 0 0 14px;
  animation: fade-up 0.35s ease both;
}

.msg-user {
  display: flex;
  justify-content: flex-end;
}

.msg-user .bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px 12px 4px 12px;
  background: var(--user-bg);
  color: var(--text-bright);
  line-height: 1.5;
}

.msg-ai {
  color: var(--text);
  line-height: 1.55;
}

/* Agent 步骤条 */
.agent-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: fade-up 0.28s ease both;
}

.step-ico {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #0d1117;
  background: var(--ok);
}

.step-ico.pending {
  background: transparent;
  border: 1.5px solid #555;
  animation: spin 0.8s linear infinite;
  border-top-color: var(--accent);
}

.step-ico.fail {
  background: var(--err);
  color: #fff;
}

.step-body {
  min-width: 0;
  flex: 1;
  color: var(--text);
}

.step-body .path {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #2a2a2a;
  color: #c9d1d9;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* 终端 Agent 块 */
.term-card {
  margin: 8px 0 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #121212;
  overflow: hidden;
  animation: fade-up 0.3s ease both;
}

.term-card.fail {
  border-color: #5c2b2b;
}

.term-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #1a1a1a;
  border-bottom: 1px solid #2c2c2c;
  color: var(--text-dim);
  font-size: 11px;
}

.term-head .ok {
  color: var(--ok);
}
.term-head .bad {
  color: var(--err);
}

.term-body {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: #b8b8b8;
  white-space: pre-wrap;
}

.term-body .cmd {
  color: #e6edf3;
}
.term-body .out-ok {
  color: #7ee787;
}
.term-body .out-err {
  color: #ff7b72;
}

/* 写入 / diff Agent */
.write-card {
  margin: 8px 0 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: var(--bg-card);
  padding: 10px 12px;
  animation: fade-up 0.3s ease both;
}

.write-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.write-row .check {
  color: var(--ok);
  font-weight: 700;
}

.write-row .file {
  font-family: var(--font-mono);
  color: var(--text-bright);
}

.diff-badges {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 650;
}

.diff-badges .del {
  color: var(--del);
}
.diff-badges .add {
  color: var(--add);
}

.badge-new {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  background: #1f6feb;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* Markdown 渲染区 */
.md {
  margin-top: 4px;
}

.md h3 {
  margin: 14px 0 8px;
  font-size: 13.5px;
  color: var(--text-bright);
}

.md p {
  margin: 0 0 8px;
}

.md ul {
  margin: 4px 0 10px;
  padding-left: 1.2em;
}

.md li {
  margin: 3px 0;
}

.md strong {
  color: var(--text-bright);
}

.md code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #2a2a2a;
}

.md pre {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0d1117;
  border: 1px solid #30363d;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: #e6edf3;
}

.md pre .k {
  color: #79c0ff;
}
.md pre .s {
  color: #a5d6ff;
}
.md pre .p {
  color: #ffa657;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px;
  font-size: 11.5px;
}

.md th,
.md td {
  border: 1px solid #3a3a3a;
  padding: 6px 8px;
  text-align: left;
}

.md th {
  background: #2a2a2a;
  color: var(--text-bright);
}

.md tr:nth-child(even) td {
  background: #222;
}

/* 输入区 */
.agent-composer {
  flex-shrink: 0;
  padding: 8px 10px 12px;
  border-top: 1px solid #2c2c2c;
  background: #1f1f1f;
}

.status-line {
  margin: 0 0 8px;
  padding: 0 4px;
  color: var(--text-dim);
  font-size: 11.5px;
}

.status-line[hidden] {
  display: none;
}

.composer-box {
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  background: #252526;
  padding: 8px 10px 8px;
}

.composer-box textarea {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.composer-box textarea::placeholder {
  color: #6e6e6e;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #1a3a52;
  color: #cde7f7;
  font-size: 11px;
}

.chev {
  opacity: 0.7;
  font-size: 10px;
}

.tool-ico {
  opacity: 0.65;
  color: var(--text-dim);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
