/* Agent Lab — 浅色工程控制台 */

:root {
  color-scheme: light;
  --paper: #f4f2ed;
  --paper-raised: #faf9f6;
  --ink: #1c1b19;
  --ink-muted: #5c5a56;
  --ink-faint: #8a8780;
  --line: #d4d0c8;
  --line-strong: #b8b3a8;
  --accent: #4a6274;
  --accent-soft: #e3e9ed;
  --accent-ink: #2f4555;
  --ok: #3d6b4f;
  --warn: #8a5c2e;
  --danger: #9b3d3d;
  --focus: #4a6274;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(28, 27, 25, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  background: var(--accent-soft);
  border-radius: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- 壳层网格 --- */

.lab-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.lab-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}

.lab-brand__en {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.lab-brand__title {
  margin: 2px 0 0;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.lab-topbar__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.lab-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.lab-back {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.lab-back:hover {
  border-bottom-color: var(--accent);
}

.lab-topbar__actions {
  flex-basis: 100%;
  display: flex;
  justify-content: flex-end;
}

@media (min-width: 720px) {
  .lab-topbar__actions {
    flex-basis: auto;
    margin-left: 0;
  }

  .lab-topbar__meta {
    margin-left: auto;
  }
}

/* --- 按钮 --- */

.lab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lab-btn:hover:not(:disabled) {
  background: #fff;
  border-color: var(--accent);
}

.lab-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.lab-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  color: var(--ink-muted);
}

.lab-btn--primary {
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent-ink);
}

.lab-btn--primary:hover:not(:disabled) {
  background: var(--accent-ink);
}

.lab-btn--ghost {
  background: transparent;
}

/* --- 主区三栏 --- */

.lab-main {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  min-height: 0;
}

.lab-panel {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  overflow: auto;
  min-height: 280px;
  background: var(--paper-raised);
}

.lab-panel--orchestrate {
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.lab-panel--tools {
  border-right: none;
}

.panel-heading {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.panel-heading--sub {
  margin-top: 20px;
}

/* --- 场景 --- */

.scenario-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-list:empty::after {
  content: "加载场景列表…";
  display: block;
  padding: 12px;
  font-size: 0.88rem;
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.field-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  resize: vertical;
  min-height: 88px;
}

.field-textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--accent);
}

.params-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- 编排与阶段 --- */

.orchestrate-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.orchestrate-head .panel-heading {
  margin-bottom: 0;
}

.phase-rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.phase__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.phase__tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.phase__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.phase__body {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.phase__placeholder {
  font-style: italic;
  color: var(--ink-faint);
}

.phase.is-active {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.phase.is-active .phase__tag {
  color: var(--accent-ink);
}

/* --- 工具轨迹（右栏） --- */

.lab-panel--tools .tool-list {
  margin-bottom: 14px;
}

.tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  max-height: min(42vh, 320px);
  overflow: auto;
}

.tool-list:empty::before {
  content: "暂无工具调用";
  display: block;
  padding: 14px;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.tool {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.tool:last-child {
  border-bottom: none;
}

.tool:hover {
  background: var(--accent-soft);
}

.tool.is-new {
  animation: tool-flash 0.6s ease;
}

@keyframes tool-flash {
  from {
    background: var(--accent-soft);
  }
  to {
    background: transparent;
  }
}

.tool-detail {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  overflow: auto;
  max-height: min(36vh, 280px);
  min-height: 120px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-detail__empty {
  margin: 0;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* --- 右栏说明 --- */

.tools-hint {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.tools-legend {
  margin: 0;
  display: grid;
  gap: 10px;
}

.tools-legend dt {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.tools-legend dd {
  margin: 2px 0 0;
  font-size: 0.88rem;
}

/* --- 底栏评测 --- */

.lab-eval {
  border-top: 1px solid var(--line);
  background: var(--paper-raised);
  padding: 16px 20px;
}

.lab-eval__inner {
  max-width: 1200px;
}

.eval-summary__placeholder {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-faint);
}

.eval-rubrics {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.eval.is-shown {
  animation: eval-reveal 0.35s ease;
}

@keyframes eval-reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- 错误与页脚 --- */

.error-box {
  margin: 0 20px 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid #e0b4b4;
  background: #faf3f3;
  color: var(--danger);
  font-size: 0.88rem;
}

.error-box[hidden] {
  display: none;
}

.lab-footer {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.disclaimer {
  margin: 0;
  max-width: 72ch;
  font-size: 0.8rem;
  color: var(--ink-muted);
  line-height: 1.55;
}

/* --- 窄屏堆叠 --- */

@media (max-width: 960px) {
  .lab-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .lab-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
    min-height: auto;
  }

  .lab-panel--tools {
    border-bottom: none;
  }

}

@media (max-width: 520px) {
  .lab-topbar {
    padding: 14px 14px;
  }

  .lab-panel,
  .lab-eval,
  .lab-footer {
    padding-left: 14px;
    padding-right: 14px;
  }
}