.ai-hub-dialog {
  width: min(96vw, 1320px);
  height: min(92vh, 920px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  background: #111216;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.58);
}

.ai-hub-dialog::backdrop {
  background: rgba(3, 4, 6, 0.78);
  backdrop-filter: blur(6px);
}

.ai-hub-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
}

.ai-hub-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.ai-hub-header .eyebrow {
  margin-bottom: 5px;
}

.ai-hub-header h2 {
  margin: 0;
  font-size: 22px;
}

.ai-hub-header p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.ai-hub-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.012);
}

.ai-hub-tabs button {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.ai-hub-tabs button[aria-selected="true"] {
  border-color: rgba(213, 165, 76, 0.32);
  color: #f8e4ba;
  background: rgba(213, 165, 76, 0.1);
}

.ai-hub-view {
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 22px;
}

.ai-chat-layout {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  gap: 12px;
  height: 100%;
}

.ai-chat-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.55fr) auto;
  gap: 10px;
  align-items: end;
}

.ai-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.ai-field input,
.ai-field select,
.ai-field textarea {
  width: 100%;
  border: 1px solid #393630;
  border-radius: 9px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
}

.ai-field input,
.ai-field select {
  min-height: 40px;
  padding: 8px 10px;
}

.ai-field textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
}

.ai-data-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 10px;
}

.ai-data-toggle input {
  accent-color: var(--gold);
}

.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
  padding: 14px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.015);
}

.ai-chat-empty {
  margin: auto;
  max-width: 520px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.55;
}

.ai-message {
  max-width: min(82%, 820px);
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.ai-message.is-user {
  align-self: flex-end;
  border-color: rgba(213, 165, 76, 0.28);
  background: rgba(213, 165, 76, 0.08);
}

.ai-message.is-assistant {
  align-self: flex-start;
  background: var(--surface);
}

.ai-message-meta {
  display: block;
  margin-top: 7px;
  color: var(--faint);
  font-size: 9px;
}

.ai-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.ai-chat-compose textarea {
  min-height: 76px;
  max-height: 180px;
}

.ai-primary,
.ai-secondary,
.ai-danger {
  min-height: 39px;
  padding: 8px 13px;
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}

.ai-primary {
  border: 1px solid var(--gold);
  color: #1b1306;
  background: var(--gold);
}

.ai-secondary {
  border: 1px solid #393630;
  color: var(--muted);
  background: transparent;
}

.ai-danger {
  border: 1px solid rgba(236, 128, 118, 0.35);
  color: var(--red);
  background: transparent;
}

.ai-primary:disabled,
.ai-secondary:disabled,
.ai-danger:disabled {
  opacity: 0.48;
  cursor: wait;
}

.ai-status-line {
  min-height: 16px;
  color: var(--green);
  font-size: 10px;
}

.ai-status-line.is-error {
  color: var(--red);
}

.ai-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ai-section-head h3 {
  margin: 0;
  font-size: 16px;
}

.ai-section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.ai-task-grid,
.ai-connection-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: 15px;
  align-items: start;
}

.ai-form-card,
.ai-list-card {
  padding: 15px;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.015);
}

.ai-form-card h4,
.ai-list-card h4 {
  margin: 0 0 12px;
  font-size: 13px;
}

.ai-form-stack {
  display: grid;
  gap: 10px;
}

.ai-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.ai-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.ai-list {
  display: grid;
  gap: 8px;
}

.ai-list-entry {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 11px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface);
}

.ai-list-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--green);
}

.ai-list-entry.is-paused .ai-list-dot {
  background: var(--faint);
}

.ai-list-entry.is-failed .ai-list-dot {
  background: var(--red);
}

.ai-list-copy {
  min-width: 0;
}

.ai-list-copy strong,
.ai-list-copy span,
.ai-list-copy small {
  display: block;
}

.ai-list-copy strong {
  font-size: 12px;
}

.ai-list-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.ai-list-copy small {
  margin-top: 5px;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.35;
}

.ai-list-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ai-list-actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 9px;
}

.ai-task-result {
  max-height: 110px;
  margin-top: 7px;
  padding: 8px;
  overflow: auto;
  border-radius: 8px;
  color: #d9d4c9;
  background: rgba(255, 255, 255, 0.025);
  font-size: 9px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.ai-connection-note {
  padding: 10px 11px;
  border: 1px solid rgba(213, 165, 76, 0.23);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(213, 165, 76, 0.045);
  font-size: 10px;
  line-height: 1.45;
}

@media (max-width: 860px) {
  .ai-hub-dialog {
    width: 98vw;
    height: 96vh;
  }

  .ai-chat-controls,
  .ai-task-grid,
  .ai-connection-grid,
  .ai-chat-compose {
    grid-template-columns: 1fr;
  }

  .ai-form-row {
    grid-template-columns: 1fr;
  }

  .ai-message {
    max-width: 94%;
  }
}
