.modeTrigger,
.activeMode {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--ant-color-border-secondary);
  border-radius: 9px;
  background: color-mix(
    in srgb,
    var(--ant-color-bg-container) 92%,
    transparent
  );
  color: var(--ant-color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.modeTrigger {
  padding: 0 9px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.modeTrigger:hover,
.modeTrigger[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--ant-color-primary) 42%, transparent);
  background: color-mix(in srgb, var(--ant-color-primary-bg) 64%, transparent);
  color: var(--ant-color-text);
}

.modeTrigger:focus-visible,
.modeOption:focus-visible,
.settingsButton:focus-visible {
  outline: 2px solid var(--ant-color-primary-border);
  outline-offset: 2px;
}

.activeMode {
  padding: 0 10px;
  color: var(--ant-color-text);
}

.activeMode[data-state="starting"] {
  border-color: color-mix(in srgb, var(--ant-color-primary) 28%, transparent);
  background: color-mix(in srgb, var(--ant-color-primary-bg) 66%, transparent);
}

.activeMode[data-state="running"] {
  border-color: color-mix(in srgb, var(--ant-color-success) 32%, transparent);
  background: color-mix(in srgb, var(--ant-color-success-bg) 70%, transparent);
}

.activeMode[data-state="awaiting_user"] {
  border-color: color-mix(in srgb, var(--ant-color-warning) 24%, transparent);
  background: color-mix(in srgb, var(--ant-color-warning-bg) 62%, transparent);
}

.activeState {
  color: var(--ant-color-text-tertiary);
  font-size: 11px;
  font-weight: 500;
}

.activeState::before {
  margin-right: 5px;
  color: var(--ant-color-text-quaternary);
  content: "·";
}

.spin {
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modePopover :global(.ant-popover-inner) {
  padding: 0;
  border: 1px solid var(--ant-color-border-secondary);
  border-radius: 14px;
  box-shadow: var(--ant-box-shadow-secondary);
  overflow: hidden;
}

.modeMenu {
  width: min(360px, calc(100vw - 24px));
  padding: 10px;
  background: var(--ant-color-bg-elevated);
}

.menuHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 6px 10px;
}

.menuTitle {
  color: var(--ant-color-text);
  font-size: 13px;
  font-weight: 650;
}

.menuHint {
  margin-top: 3px;
  color: var(--ant-color-text-tertiary);
  font-size: 11px;
}

.settingsButton {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ant-color-text-tertiary);
  cursor: pointer;
}

.settingsButton:hover {
  background: var(--ant-color-fill-tertiary);
  color: var(--ant-color-text);
}

.modeGroup + .modeGroup {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--ant-color-split);
}

.groupLabel {
  padding: 4px 7px 5px;
  color: var(--ant-color-text-quaternary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modeOption {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ant-color-text-tertiary);
  text-align: left;
  cursor: pointer;
}

.modeOption:hover,
.modeOption.selected {
  background: var(--ant-color-fill-quaternary);
}

.modeOption.selected {
  color: var(--ant-color-primary);
}

.optionIcon {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--ant-color-fill-tertiary);
  color: var(--ant-color-text-secondary);
}

.selected .optionIcon {
  background: var(--ant-color-primary-bg);
  color: var(--ant-color-primary);
}

.optionCopy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.optionName {
  overflow: hidden;
  color: var(--ant-color-text);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.optionDescription {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ant-color-text-tertiary);
  font-size: 11px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.menuError {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 6px 2px;
  color: var(--ant-color-error);
  font-size: 11px;
}

.menuError button {
  padding: 2px 5px;
  border: 0;
  background: transparent;
  color: var(--ant-color-primary);
  font: inherit;
  cursor: pointer;
}
