.ai-dialog-panel {
  width: min(48rem, calc(100vw - 2rem));
  height: min(44rem, calc(100vh - 2rem));
}

.ai-chat-body {
  min-height: 0;
  padding: 0;
  gap: 0;
}

.ai-chat-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.ai-model-control,
.ai-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ai-model-control > span {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ai-model-control select,
.ai-quick-actions button {
  height: 1.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  color: #334155;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
}

.ai-model-control select { padding: 0 1.8rem 0 0.45rem; }
.ai-quick-actions button { padding: 0 0.55rem; cursor: pointer; }
.ai-quick-actions button:hover,
.ai-quick-actions button:focus-visible {
  border-color: #60a5fa;
  background: #dbeafe;
  color: #1d4ed8;
}

.ai-chat-messages {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 1rem;
}

.ai-chat-empty {
  max-width: 30rem;
  margin: 4rem auto;
  color: #64748b;
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
}

.ai-chat-message {
  max-width: 88%;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #dbe3ee;
  border-radius: 7px;
  background: #f8fafc;
  color: #334155;
  font-size: 0.86rem;
  line-height: 1.52;
  white-space: pre-wrap;
}

.ai-chat-message.user {
  margin-left: auto;
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.ai-chat-message.assistant {
  margin-right: auto;
}

.ai-chat-message p { margin: 0 0 0.65rem; }
.ai-chat-message p:last-child { margin-bottom: 0; }
.ai-chat-message pre {
  margin: 0.65rem 0;
  padding: 0.65rem;
  overflow: auto;
  border: 1px solid #d8e0ec;
  border-radius: 5px;
  background: #ffffff;
  color: #243247;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre;
}
.ai-chat-message code {
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.18);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.ai-chat-status {
  min-height: 0;
  padding: 0 1rem;
  color: #64748b;
  font-size: 0.76rem;
}
.ai-chat-status.error { color: #b91c1c; }

.ai-chat-composer {
  border-top: 1px solid #e2e8f0;
  padding: 0.75rem;
}

.ai-chat-composer textarea {
  display: block;
  width: 100%;
  min-height: 4.4rem;
  resize: vertical;
  border: 1px solid #bfcddd;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  font: inherit;
  line-height: 1.45;
  padding: 0.55rem 0.65rem;
}
.ai-chat-composer textarea:focus {
  outline: 3px solid rgba(96, 165, 250, 0.25);
  border-color: #60a5fa;
  box-shadow: none;
}

.ai-chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.55rem;
}
.ai-chat-composer-actions .secondary {
  width: 2.15rem;
  padding: 0;
}
.ai-chat-composer-actions .app-icon { width: 1rem; height: 1rem; }

[data-theme="dark"] .ai-chat-message {
  border-color: #3a404c;
  background: #1f2229;
  color: #d7dce4;
}
[data-theme="dark"] .ai-chat-message.user {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(96, 165, 250, 0.16);
  color: #93c5fd;
}
[data-theme="dark"] .ai-chat-message pre {
  border-color: #3a404c;
  background: #171a21;
  color: #d7dce4;
}
[data-theme="dark"] .ai-chat-message code { background: rgba(148, 163, 184, 0.2); }
[data-theme="dark"] .ai-chat-composer { border-top-color: #3a404c; }
[data-theme="dark"] .ai-chat-controls { border-bottom-color: #3a404c; background: #1f2229; }
[data-theme="dark"] .ai-model-control > span { color: #9aa5b5; }
[data-theme="dark"] .ai-model-control select,
[data-theme="dark"] .ai-quick-actions button {
  border-color: #3a404c;
  background: #171a21;
  color: #d7dce4;
}
[data-theme="dark"] .ai-quick-actions button:hover,
[data-theme="dark"] .ai-quick-actions button:focus-visible {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.18);
  color: #93c5fd;
}
[data-theme="dark"] .ai-chat-composer textarea {
  border-color: #3a404c;
  background: #171a21;
  color: #d7dce4;
}
[data-theme="dark"] .ai-chat-composer textarea:focus {
  outline: 3px solid rgba(96, 165, 250, 0.28);
  border-color: #60a5fa;
}
[data-theme="dark"] .ai-chat-empty,
[data-theme="dark"] .ai-chat-status { color: #9aa5b5; }
[data-theme="dark"] .ai-chat-status.error { color: #fca5a5; }
