* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f1419; color: #e6e9ec;
}
#app { display: flex; height: calc(100% - 104px); }

/* ---------- 页脚 ---------- */
.site-footer {
  height: 104px;
  padding: 14px 20px;
  border-top: 1px solid #2a313a;
  background: #161b22;
  color: #8b949e;
  text-align: center;
  font-size: 13px;
  line-height: 1.75;
}
.site-footer p + p { margin-top: 2px; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: #58a6ff; text-decoration: underline; }
.site-footer .separator { margin: 0 12px; color: #6e7681; }

@media (max-width: 640px) {
  #app { height: calc(100% - 128px); }
  .site-footer { height: 128px; padding: 10px 12px; font-size: 12px; }
  .site-footer .separator { margin: 0 6px; }
}

/* ---------- 侧栏 ---------- */
#sidebar {
  width: 400px; min-width: 340px; height: 100%;
  overflow-y: auto; padding: 16px;
  background: #161b22; border-right: 1px solid #2a313a;
  display: flex; flex-direction: column; gap: 14px;
}
/* 禁止被进度面板挤扁：侧栏整体滚动，面板保持内容高度 */
#sidebar > header,
#sidebar > .panel { flex-shrink: 0; }
header h1 { font-size: 20px; color: #58a6ff; }
header .sub { font-size: 12px; color: #8b949e; margin-top: 2px; }

.panel {
  background: #1c2129; border: 1px solid #2a313a;
  border-radius: 10px; padding: 12px;
}
.panel h2 { font-size: 14px; color: #c9d1d9; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }

.model-row { display: flex; gap: 6px; margin-bottom: 8px; }
.history-row { display: flex; gap: 6px; margin-bottom: 8px; }
.history-row select { flex: 1; }
.history-row .mini { flex: 0 0 auto; }
.field-label {
  font-size: 11px; color: #8b949e; margin-bottom: 4px;
}
.ds-group.highlight {
  border-color: #58a6ff;
  box-shadow: 0 0 0 1px #58a6ff55;
}
select, textarea, input {
  width: 100%; background: #0f1419; color: #e6e9ec;
  border: 1px solid #2a313a; border-radius: 6px;
  padding: 8px; font-size: 13px; font-family: inherit;
}
textarea { resize: vertical; }
button {
  background: #1f6feb; color: #fff; border: none; border-radius: 6px;
  padding: 9px 12px; font-size: 13px; cursor: pointer; width: 100%;
}
button:hover { background: #388bfd; }
button:disabled { background: #30363d; cursor: not-allowed; }
button.mini, #model-refresh {
  width: auto; padding: 4px 8px; font-size: 12px;
  background: #21262d; border: 1px solid #2a313a;
}
#model-refresh { flex: 0 0 auto; }

/* ---------- 进度 ---------- */
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: #1f6feb33; color: #58a6ff; margin-left: 6px;
}
.badge.done { background: #23863633; color: #3fb950; }
.badge.failed { background: #da363333; color: #f85149; }
#progress-log {
  max-height: 260px; overflow-y: auto; font-size: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.log-item { padding: 5px 8px; border-radius: 6px; background: #0f1419; line-height: 1.5; }
.log-item .t { color: #6e7681; margin-right: 6px; font-size: 11px; }
.log-item.llm { border-left: 3px solid #a371f7; }
.log-item.thought { border-left: 3px solid #d29922; color: #d4c17f; }
.log-item.action { border-left: 3px solid #58a6ff; }
.log-item.result { border-left: 3px solid #3fb950; }
.log-item.dataset { border-left: 3px solid #3fb950; background: #23863322; }
.log-item.warn { border-left: 3px solid #f0883e; color: #f0b06e; }
.log-item.error { border-left: 3px solid #f85149; color: #ff9b95; }
.log-item.done { border-left: 3px solid #3fb950; font-weight: 600; }

/* ---------- 数据列表 ---------- */
/* 不用 flex 子项收缩：条目多时必须靠滚动展示，否则会被压成接近 0 高度 */
#dataset-list {
  max-height: min(52vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 120px;
}
.ds-group {
  border: 1px solid #2a313a;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.ds-group:last-child { margin-bottom: 0; }
.ds-group-head {
  padding: 8px 10px; background: #21262d; font-size: 13px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  min-height: 36px;
}
.ds-group-head .q {
  font-weight: 600; color: #c9d1d9;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1;
}
.ds-group-head .meta { font-size: 11px; color: #8b949e; flex: 0 0 auto; margin-left: 8px; }
.ds-items { display: block; }
.ds-item {
  padding: 8px 10px; font-size: 12px; cursor: pointer;
  border-top: 1px solid #2a313a;
  display: flex; align-items: center; gap: 8px;
  min-height: 40px;
  box-sizing: border-box;
}
.ds-item:hover { background: #1f6feb22; }
.ds-item.active { background: #1f6feb33; }
.ds-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.ds-item .info { flex: 1; min-width: 0; }
.ds-item .nm { color: #e6e9ec; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-item .src { color: #8b949e; font-size: 11px; }
.ds-item .cnt { color: #6e7681; font-size: 11px; flex: 0 0 auto; }
.ds-item .ops { flex: 0 0 auto; display: flex; gap: 4px; }
.ds-item .ops span { color: #6e7681; cursor: pointer; padding: 0 3px; }
.ds-item .ops span:hover { color: #f85149; }

.src-tag {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: #30363d; color: #8b949e; margin-left: 4px;
}
.src-tag.llm { background: #6e40c933; color: #a371f7; }

/* ---------- 地图 ---------- */
#map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }
#legend {
  position: absolute; right: 12px; top: 12px; z-index: 5;
  background: #161b22ee; border: 1px solid #2a313a; border-radius: 8px;
  padding: 8px 12px; font-size: 12px; max-width: 300px; display: none;
}
#legend .row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
#legend .sw { width: 14px; height: 14px; border-radius: 3px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: #000a; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-body {
  width: min(860px, 92vw); max-height: 86vh; overflow-y: auto;
  background: #161b22; border: 1px solid #2a313a; border-radius: 12px; padding: 16px;
}
.modal-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.modal-head button { width: auto; background: #21262d; padding: 4px 10px; }
.rec-event { font-size: 12px; padding: 6px 8px; border-bottom: 1px solid #21262d; }
.rec-event .k { color: #58a6ff; }
.rec-event pre {
  white-space: pre-wrap; word-break: break-all; color: #8b949e;
  max-height: 140px; overflow-y: auto; margin-top: 4px; font-size: 11px;
}
a.rec-link { color: #58a6ff; cursor: pointer; font-size: 11px; margin-left: 8px; }
