.studio-run-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.studio-run-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  min-height: 0;
}

.studio-run-chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.studio-run-chat-message {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  line-height: 1.6;
}

.studio-run-chat-message.role-user {
  align-self: flex-end;
  max-width: 85%;
  background: linear-gradient(to right, rgba(102, 126, 234, 0.08), rgba(102, 126, 234, 0.15));
  border-left: 3px solid var(--color-accent);
}

.studio-run-chat-message.role-assistant,
.studio-run-chat-message.role-system {
  align-self: stretch;
  background: rgba(255, 255, 255, 0.6);
}

[data-color-theme='dark'] .studio-run-chat-message.role-assistant,
[data-color-theme='dark'] .studio-run-chat-message.role-system {
  background-color: rgba(45, 45, 48, 0.5);
  color: var(--color-text-primary);
}

.studio-run-chat-focus {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  min-height: min(40vh, 320px);
}

.studio-run-chat-thinking,
.studio-run-chat-summary {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  background: var(--color-bg-primary);
}

[data-color-theme='dark'] .studio-run-chat-thinking,
[data-color-theme='dark'] .studio-run-chat-summary {
  background-color: rgba(45, 45, 48, 0.5);
  border-color: var(--color-border);
}

.studio-run-chat-thinking--pending {
  border-style: dashed;
}

.studio-run-chat-block-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--spacing-sm);
}

.studio-run-chat-block-body {
  font-size: 0.95rem;
  color: var(--color-text-primary);
  line-height: 1.6;
}

.studio-run-chat-message-role {
  display: block;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-xs);
}

.studio-run-chat-message-body {
  font-size: 0.95rem;
}

.studio-run-chat-plain {
  white-space: pre-wrap;
}

/* Input area — aligned with ChatBox */
.studio-run-chat-input-wrapper {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  flex-shrink: 0;
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--color-border-light);
  background-color: var(--color-bg-primary);
  z-index: var(--z-divider);
}

.studio-run-chat-input-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.studio-run-chat-input-container:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

[data-color-theme='dark'] .studio-run-chat-input-container {
  background-color: var(--color-bg-tertiary);
  box-shadow: none;
}

[data-color-theme='dark'] .studio-run-chat-input-container:focus-within {
  box-shadow: 0 0 0 1px var(--color-accent);
}

[data-color-theme='dark'] .studio-run-chat-options-toggle:hover,
[data-color-theme='dark'] .studio-run-chat-options-toggle.active {
  background-color: var(--color-accent-ultra-light);
}

[data-color-theme='dark'] .studio-run-chat-textarea:focus {
  background-color: transparent;
}

.studio-run-chat-options-wrapper {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.studio-run-chat-options-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.studio-run-chat-options-toggle:hover {
  background-color: rgba(102, 126, 234, 0.08);
  color: var(--color-accent);
}

.studio-run-chat-options-toggle.active {
  background-color: rgba(102, 126, 234, 0.12);
  color: var(--color-accent);
}

.studio-run-chat-options {
  position: absolute;
  bottom: calc(100% + var(--spacing-sm));
  left: 0;
  min-width: 220px;
  padding: var(--spacing-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: var(--z-dropdown-menu);
  backdrop-filter: blur(10px);
}

.studio-run-chat-options-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--spacing-xs) var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.studio-run-chat-render-btn {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.studio-run-chat-render-btn:hover {
  background-color: rgba(102, 126, 234, 0.08);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.studio-run-chat-option-checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  margin-bottom: var(--spacing-xs);
}

.studio-run-chat-option-checkbox:hover {
  background-color: rgba(102, 126, 234, 0.06);
}

.studio-run-chat-option-checkbox input[type="checkbox"] {
  display: none;
}

.studio-run-chat-checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-radius: 3px;
  position: relative;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.studio-run-chat-option-checkbox:hover .studio-run-chat-checkmark {
  border-color: var(--color-accent);
}

.studio-run-chat-option-checkbox input:checked + .studio-run-chat-checkmark {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.studio-run-chat-option-checkbox input:checked + .studio-run-chat-checkmark::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.studio-run-chat-option-label {
  font-size: 0.85rem;
  color: var(--color-text-primary);
}

.studio-run-chat-pending {
  color: var(--color-text-muted);
  font-style: italic;
}

.studio-run-chat-message.is-pending {
  opacity: 0.85;
}

.studio-run-chat-input-area {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}

.studio-run-chat-textarea {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--radius-md);
  background-color: transparent;
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  overflow-y: auto;
  min-height: 36px;
  max-height: 300px;
  line-height: 1.6;
  display: block;
  height: auto;
  field-sizing: content;
}

.studio-run-chat-textarea:focus {
  outline: none;
  background-color: rgba(102, 126, 234, 0.03);
}

.studio-run-chat-textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 0.5;
}

.studio-run-chat-send {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
  align-self: center;
}

.studio-run-chat-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.studio-run-chat-send:active:not(:disabled) {
  transform: translateY(0);
}

.studio-run-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.studio-run-chat-send--stopping {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  animation: studio-run-chat-pulse 1.5s infinite;
}

@keyframes studio-run-chat-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}
