/* ============================================================
   AI 助手面板样式
   ============================================================ */

.app.ai-open { grid-template-columns: 250px 340px minmax(0, 1fr) 380px; }

@media (min-width: 900px) and (max-width: 1399px) {
  .app.ai-open { grid-template-columns: 220px 300px minmax(0, 1fr) 340px; }
}

.ai-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}
.ai-title { font-weight: 700; font-size: 14px; white-space: nowrap; }
.ai-model {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 999px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.ai-banner button {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.8;
  background: var(--panel-2);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
}
.ai-hint p { margin: 0 0 6px; color: var(--text-2); }
.ai-hint ul { margin: 0; padding-left: 18px; }
.ai-hint li { margin: 2px 0; }

.msg { display: flex; flex-direction: column; gap: 5px; }
.msg.user { align-items: flex-end; }
.msg .bubble {
  max-width: 100%;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.72;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: var(--accent);
  color: #fff;
  white-space: pre-wrap;
  border-bottom-right-radius: 4px;
}
.msg.assistant .bubble {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.assistant .bubble.markdown-body { font-size: 13px; }
.msg.assistant .bubble.markdown-body h1 { font-size: 1.25em; }
.msg.assistant .bubble.markdown-body h2 { font-size: 1.12em; }
.msg.assistant .bubble.markdown-body h3 { font-size: 1.02em; }
.msg.assistant .bubble.markdown-body pre { font-size: 12px; }
.msg.assistant .bubble.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.msg-files { display: flex; flex-wrap: wrap; gap: 4px; }
.file-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.user .file-chip { color: var(--text-2); }

.msg-actions { display: flex; gap: 10px; padding: 0 2px; }
.msg-actions button { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.msg-actions button:hover { text-decoration: underline; }

.ai-typing { display: flex; gap: 4px; align-items: center; height: 18px; }
.ai-typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted);
  animation: ai-blink 1.2s infinite;
}
.ai-typing i:nth-child(2) { animation-delay: .2s; }
.ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.ai-pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.ai-pending:not(:empty) { padding-bottom: 8px; }
.ai-pending:empty { display: none; }
.pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  max-width: 100%;
}
.pending-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.pending-chip button {
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  padding: 0 3px;
  border-radius: 50%;
}
.pending-chip button:hover { background: rgba(79, 70, 229, .18); }

.ai-composer { border-top: 1px solid var(--border); padding: 10px 12px 12px; }
#ai-input {
  width: 100%;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--panel-2);
  outline: none;
  font-size: 13px;
  line-height: 1.6;
  max-height: 160px;
}
#ai-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ai-check { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.ai-check input { margin: 0; }

/* ------------------------------ 弹窗 ------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: grid;
  place-items: center;
  z-index: 300;
  padding: 20px;
}
.modal-card {
  width: min(430px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow-lg);
}
.modal-card h3 { margin: 0 0 6px; font-size: 16px; }
.modal-card .field { margin-bottom: 12px; }
.modal-card code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}
.cfg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0 10px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.ai-pane.drag { outline: 2px dashed var(--accent); outline-offset: -8px; background: var(--accent-soft); }

.chip-btn.ai.on { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (max-width: 899px) {
  .ai-pane {
    position: fixed;
    inset: 0;
    z-index: 70;
    border-left: none;
  }
}
