* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #f3f6f9;
  color: #1a202c;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #edf2f7;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #0b5fff;
  color: #fff;
  flex-wrap: wrap;
}
.title-wrap { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.title-wrap h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.subtitle { font-size: 12px; opacity: .86; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.35);
  white-space: nowrap;
}
.badge.ok { background: rgba(72,187,120,.28); border-color: rgba(72,187,120,.7); }
.badge.bad { background: rgba(229,62,62,.28); border-color: rgba(229,62,62,.75); }

.safety-banner {
  margin: 10px 14px 0;
  padding: 9px 12px;
  border: 1px solid #f6c76b;
  background: #fff8e6;
  color: #744210;
  border-radius: 7px;
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 350px minmax(460px, 1fr) 340px;
  gap: 12px;
  padding: 12px 14px 4px;
  align-items: start;
}
@media (max-width: 1320px) {
  .layout { grid-template-columns: 340px minmax(420px, 1fr); }
  .settings-panel { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .settings-panel { grid-column: auto; }
}

.panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(16, 42, 67, .04);
  min-width: 0;
}
.panel h2 { margin: 0 0 10px; font-size: 16px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mission-title { font-size: 13px; color: #0b5fff; font-weight: 600; text-align: right; }

.footer {
  padding: 10px 18px 16px;
  color: #718096;
  font-size: 12px;
}

/* ---------- 对话 ---------- */
.chat-panel { display: flex; flex-direction: column; }
.chatlog {
  height: 265px;
  overflow-y: auto;
  border: 1px solid #edf2f7;
  background: #fbfdff;
  border-radius: 7px;
  padding: 8px;
  margin-bottom: 8px;
}
.chat-empty { color: #a0aec0; font-size: 12.5px; line-height: 1.6; padding: 6px; }
.chat-msg {
  margin: 6px 0;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 96%;
}
.chat-msg.user { background: #e6efff; margin-left: auto; }
.chat-msg.assistant { background: #f1f5f9; }
.chat-msg.error { background: #fff5f5; border: 1px solid #feb2b2; color: #9b2c2c; }
.chat-msg.system { background: #f0fff4; border: 1px dashed #9ae6b4; color: #276749; }

#prompt {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  padding: 9px;
  border: 1px solid #cbd5e0;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
}
#prompt:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(11,95,255,.25);
  border-color: #0b5fff;
}

.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.example {
  background: #edf2f7;
  color: #2d3748;
  border: 1px solid #e2e8f0;
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 999px;
}
.example:hover { background: #e2e8f0; }

/* ---------- 按钮与表单 ---------- */
button {
  border: none;
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 13px;
  cursor: pointer;
  background: #e2e8f0;
  color: #2d3748;
}
button:hover { filter: brightness(.97); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
button.primary { background: #0b5fff; color: #fff; }
button.danger { background: #e53e3e; color: #fff; }
button.ghost { background: #fff; color: #2d3748; border: 1px solid #cbd5e0; }
button.small { padding: 4px 8px; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
.actions { margin-top: 10px; }
.actions button { flex: 1 1 140px; }

.check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #4a5568; margin-top: 7px; }
.hint { color: #718096; font-size: 11.5px; line-height: 1.5; }
.notice {
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid #f6c76b;
  background: #fffaf0;
  color: #7b341e;
  font-size: 12px;
  margin-bottom: 8px;
  line-height: 1.5;
}
.hidden { display: none !important; }

.field { margin-top: 8px; }
.field label { display: block; font-size: 12px; color: #4a5568; margin-bottom: 3px; }
.field input, .field select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
  background: #fff;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 8px; }
.preset {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #edf2f7;
  border: 1px solid #e2e8f0;
}

/* ---------- 预览 ---------- */
.preview-panel { display: flex; flex-direction: column; }
#plotCanvas {
  width: 100%;
  height: 310px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfdff;
  margin-top: 6px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 0; }
.chip {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #2d3748;
  border: 1px solid #e2e8f0;
}
.chip.warn { background: #fffaf0; border-color: #f6ad55; color: #7b341e; }
.chip.ok { background: #f0fff4; border-color: #9ae6b4; color: #276749; }

.table-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  overflow: auto;
  max-height: 255px;
}
.wp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.wp-table th, .wp-table td {
  padding: 5px 7px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  white-space: nowrap;
}
.wp-table th {
  position: sticky;
  top: 0;
  background: #f7fafc;
  color: #4a5568;
  font-weight: 600;
  z-index: 1;
}
.wp-table tr:hover td { background: #f7fbff; }
.wp-table .empty-row { text-align: center; color: #a0aec0; padding: 18px; }
.action-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.validation-box {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid #feb2b2;
  background: #fff5f5;
  color: #742a2a;
  font-size: 12px;
  line-height: 1.55;
  max-height: 140px;
  overflow: auto;
}
.validation-box.has-warn { border-color: #f6c76b; background: #fffaf0; color: #744210; }
.validation-box ul { margin: 4px 0 0; padding-left: 18px; }
.validation-box .vtitle { font-weight: 600; }

.json-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.json-preview {
  width: 100%;
  height: 150px;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid #cbd5e0;
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  background: #fbfdff;
  resize: vertical;
}
.json-preview.editing { background: #fff; border-color: #0b5fff; }

.result-box {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  background: #1a202c;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ---------- 设置 ---------- */
.settings-panel { max-height: calc(100vh - 150px); overflow-y: auto; }
.settings-panel details {
  border-top: 1px solid #edf2f7;
  padding: 8px 0 10px;
}
.settings-panel details:first-of-type { border-top: none; }
.settings-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #2d3748;
  padding: 3px 0;
  user-select: none;
}
.settings-panel summary:hover { color: #0b5fff; }
