/* ========================================================================
   ai-workbench.css —— 首页 AI 工作台
   ======================================================================== */
.workbench-page {
  padding-top: 76px;
  min-height: 100vh;
}
.ai-studio {
  position: relative;
  z-index: 1;
  padding: 100px 48px;
  max-width: 1280px;
  margin: 0 auto;
}
.ai-studio-desc {
  margin: -18px auto 34px;
  max-width: 640px;
  text-align: center;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.wb {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 640px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(6, 10, 16, 0.55);
}

/* ---------- 侧栏 ---------- */
.wb-side {
  padding: 16px 14px 20px;
  border-right: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.015);
  overflow-y: auto;
  max-height: 720px;
}
.wb-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 10px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-muted);
}
.wb-side-head:first-child { margin-top: 0; }
.wb-mini {
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.25s;
}
.wb-mini:hover { border-color: var(--accent); color: var(--accent-light); }

.wb-agents { display: flex; flex-direction: column; gap: 6px; }
.wb-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: all 0.25s;
}
.wb-agent:hover { background: rgba(255, 255, 255, 0.03); }
.wb-agent.active {
  background: rgba(58, 123, 213, 0.12);
  border-color: rgba(58, 123, 213, 0.45);
  color: var(--text-primary);
}
.wb-agent-avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #3a7bd5, #2fbfa0);
}
.wb-agent-body { min-width: 0; flex: 1; }
.wb-agent-body strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-agent-body em {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-agent-tools { display: flex; gap: 4px; flex: 0 0 auto; }
.wb-agent-tools button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.wb-agent-tools button:hover { color: #ff9b9b; border-color: rgba(192, 85, 85, 0.55); }

.wb-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.wb-skill {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.25s;
}
.wb-skill:hover { border-color: var(--accent); color: var(--accent-light); }
.wb-skill.active {
  background: rgba(201, 165, 76, 0.14);
  border-color: rgba(201, 165, 76, 0.55);
  color: var(--gold);
}

.wb-prompts, .wb-history { display: flex; flex-direction: column; gap: 4px; }
.wb-prompt, .wb-history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}
.wb-prompt:hover, .wb-history-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-primary); }
.wb-prompt span, .wb-history-item span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-prompt .wb-del, .wb-history-item .wb-del {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 12px;
}
.wb-prompt .wb-del:hover, .wb-history-item .wb-del:hover { color: #ff9b9b; }
.wb-history-item.active { background: rgba(58, 123, 213, 0.1); color: var(--text-primary); }
.wb-side-empty { padding: 4px 8px; font-size: 11px; color: var(--text-muted); }

.wb-inline-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.wb-inline-form[hidden] { display: none; }
.wb-inline-form input,
.wb-inline-form textarea {
  width: 100%;
  padding: 7px 9px;
  background: rgba(6, 10, 16, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
}
.wb-inline-form textarea { min-height: 70px; resize: vertical; }
.wb-inline-form .wb-inline-actions { display: flex; gap: 6px; }
.wb-inline-form button {
  flex: 1;
  padding: 6px 0;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
}
.wb-inline-form button[data-act="save"] {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

/* ---------- 主区 ---------- */
.wb-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 640px;
}
.wb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-color);
}
.wb-model {
  min-width: 0;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-model strong { color: var(--text-primary); font-weight: 600; }
.wb-model .wb-warn { color: #e0b46a; }
.wb-config-btn {
  flex: 0 0 auto;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.25s;
}
.wb-config-btn:hover { border-color: var(--accent); color: var(--accent-light); }

.wb-chat {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  max-height: 560px;
  min-height: 380px;
}
.wb-empty {
  height: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--text-muted);
}
.wb-empty h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}
.wb-empty p { max-width: 420px; font-size: 13px; line-height: 1.8; }
.wb-starters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.wb-starter {
  padding: 7px 13px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.25s;
}
.wb-starter:hover { border-color: var(--accent); color: var(--accent-light); }

.wb-msg { margin-bottom: 20px; }
.wb-msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 11px;
  color: var(--text-muted);
}
.wb-msg-head .wb-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #3a7bd5, #2fbfa0);
}
.wb-msg--user .wb-msg-head { justify-content: flex-end; }
.wb-msg--user .wb-avatar { background: linear-gradient(135deg, #c9a54c, #8f6fe0); }
.wb-msg-copy {
  margin-left: auto;
  padding: 1px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.wb-msg:hover .wb-msg-copy { opacity: 1; }
.wb-msg-copy:hover { color: var(--accent-light); }
.wb-msg--user .wb-msg-copy { margin-left: 0; margin-right: auto; order: -1; }

.wb-bubble {
  padding: 13px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-primary);
  word-break: break-word;
}
.wb-msg--user .wb-bubble {
  margin-left: auto;
  max-width: 86%;
  background: rgba(58, 123, 213, 0.14);
  border: 1px solid rgba(58, 123, 213, 0.28);
  white-space: pre-wrap;
}
.wb-msg--assistant .wb-bubble {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-color);
}
.wb-bubble.is-streaming { white-space: pre-wrap; }
.wb-bubble.is-streaming::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 14px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--accent-light);
  animation: wbBlink 1s steps(2, start) infinite;
}
@keyframes wbBlink { 50% { opacity: 0; } }
.wb-bubble.is-error {
  border-color: rgba(192, 85, 85, 0.5);
  background: rgba(192, 85, 85, 0.07);
  color: #ffb3b3;
}

/* Markdown */
.wb-bubble p { margin: 0 0 10px; }
.wb-bubble p:last-child { margin-bottom: 0; }
.wb-bubble h1, .wb-bubble h2, .wb-bubble h3, .wb-bubble h4 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.wb-bubble h1 { font-size: 18px; }
.wb-bubble h2 { font-size: 16px; }
.wb-bubble ul, .wb-bubble ol { margin: 0 0 10px; padding-left: 22px; }
.wb-bubble li { margin: 3px 0; }
.wb-bubble blockquote {
  margin: 10px 0;
  padding: 4px 12px;
  border-left: 2px solid var(--gold);
  color: var(--text-secondary);
}
.wb-bubble a { color: var(--accent-light); text-decoration: underline; }
.wb-bubble hr { border: none; border-top: 1px solid var(--border-color); margin: 14px 0; }
.wb-bubble code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #f0d7a4;
}
.wb-code {
  position: relative;
  margin: 10px 0;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.wb-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.wb-code-head button {
  padding: 1px 7px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
}
.wb-code-head button:hover { color: var(--accent-light); border-color: var(--accent); }
.wb-code pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #d9e4f2;
}
.wb-code pre code { padding: 0; background: none; color: inherit; }

/* ---------- 输入区 ---------- */
.wb-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
}
.wb-composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  max-height: 160px;
  padding: 12px 14px;
  resize: none;
  background: rgba(6, 10, 16, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.wb-composer textarea::placeholder { color: var(--text-muted); }
.wb-composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
.wb-send {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 26px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.25s;
}
.wb-send:hover { background: var(--accent-light); border-color: var(--accent-light); }
.wb-send.is-stop { background: rgba(192, 85, 85, 0.85); border-color: rgba(192, 85, 85, 0.85); }
.wb-meta {
  padding: 0 20px 12px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.wb-meta .is-err { color: #e08a8a; }
.wb-meta button {
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
}
.wb-meta button:hover { color: var(--text-secondary); }

/* ---------- 弹层 ---------- */
.wb-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 5, 9, 0.78);
  backdrop-filter: blur(4px);
}
.wb-modal[hidden] { display: none; }
.wb-modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 28px;
  background: #0b1119;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.wb-modal-card h3 {
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.wb-modal-tip { margin-bottom: 18px; font-size: 12px; line-height: 1.7; color: var(--text-muted); }
.wb-field { margin-bottom: 14px; }
.wb-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.wb-field input, .wb-field select, .wb-field textarea {
  width: 100%;
  padding: 9px 11px;
  background: rgba(6, 10, 16, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
}
.wb-field textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
.wb-field input:focus, .wb-field select:focus, .wb-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.wb-field select option { background: #0b1119; }
.wb-field-row { display: flex; gap: 12px; }
.wb-field-row .wb-field { flex: 1; }
.wb-range { display: flex; align-items: center; gap: 10px; }
.wb-range input[type="range"] { flex: 1; accent-color: #3a7bd5; }
.wb-range output { flex: 0 0 34px; font-size: 12px; color: var(--text-secondary); text-align: right; }
.wb-modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.wb-btn {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s;
}
.wb-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.wb-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.wb-btn.primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.wb-btn.danger { flex: 0 0 auto; padding-left: 18px; padding-right: 18px; }
.wb-btn.danger:hover { border-color: rgba(192, 85, 85, 0.6); color: #ff9b9b; }
.wb-modal-status { min-height: 18px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.wb-modal-status.is-err { color: #e08a8a; }
.wb-modal-status.is-ok { color: #67d2a8; }

@media (max-width: 1024px) {
  .ai-studio { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 860px) {
  .ai-studio { padding: 70px 20px; }
  .wb { grid-template-columns: 1fr; }
  .wb-side {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    max-height: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
  }
  .wb-main { min-height: 520px; }
  .wb-chat { max-height: 420px; }
  .wb-msg--user .wb-bubble { max-width: 94%; }
  .wb-field-row { flex-direction: column; gap: 0; }
}
@media (max-width: 560px) {
  .wb-side { grid-template-columns: 1fr; }
  .wb-composer { flex-direction: column; align-items: stretch; }
  .wb-send { width: 100%; }
}
